هوش داده افلاطون
جستجوی عمودی و هوش مصنوعی

مدل های پایه Mistral 7B از Mistral AI اکنون در Amazon SageMaker در دسترس هستند JumpStart | خدمات وب آمازون

تاریخ:

امروز، ما با هیجان اعلام می کنیم که مدل های پایه Mistral 7B که توسط Mistral AI توسعه یافته است، برای مشتریان در دسترس هستند. Amazon SageMaker JumpStart برای استقرار با یک کلیک برای اجرای استنتاج. با 7 میلیارد پارامتر، Mistral 7B را می توان به راحتی سفارشی کرد و به سرعت مستقر کرد. می‌توانید این مدل را با SageMaker JumpStart امتحان کنید، یک مرکز یادگیری ماشین (ML) که دسترسی به الگوریتم‌ها و مدل‌ها را فراهم می‌کند تا بتوانید به سرعت با ML شروع کنید. در این پست به نحوه کشف و استقرار مدل Mistral 7B می پردازیم.

Mistral 7B چیست؟

Mistral 7B یک مدل پایه است که توسط Mistral AI توسعه یافته و از توانایی های تولید متن و کد انگلیسی پشتیبانی می کند. از انواع موارد استفاده مانند خلاصه سازی متن، طبقه بندی، تکمیل متن و تکمیل کد پشتیبانی می کند. برای نشان دادن قابلیت سفارشی‌سازی آسان مدل، Mistral AI مدل Mistral 7B Instruct را نیز برای موارد استفاده از چت منتشر کرده است که با استفاده از مجموعه‌های داده‌های مکالمه در دسترس عموم به‌خوبی تنظیم شده است.

Mistral 7B یک مدل ترانسفورماتور است و از توجه جستجوی گروهی و توجه پنجره کشویی برای دستیابی به استنتاج سریعتر (تأخیر کم) و مدیریت توالی های طولانی تر استفاده می کند. توجه پرس و جو گروهی معماری است که توجه چند پرس و جو و چند سر را برای دستیابی به کیفیت خروجی نزدیک به توجه چند سر و سرعت قابل مقایسه با توجه چند پرس و جو ترکیب می کند. توجه پنجره کشویی از لایه‌های انباشته یک ترانسفورماتور برای حضور در گذشته فراتر از اندازه پنجره برای افزایش طول زمینه استفاده می‌کند. Mistral 7B دارای طول زمینه 8,000 توکن است، تأخیر کم و توان عملیاتی بالا را نشان می‌دهد و در مقایسه با مدل‌های جایگزین بزرگتر، عملکرد قوی دارد و نیازهای حافظه کم را در اندازه مدل 7B فراهم می‌کند. این مدل تحت مجوز در دسترس است مجوز Apache 2.0، برای استفاده بدون محدودیت.

SageMaker JumpStart چیست؟

با SageMaker JumpStart، پزشکان ML می‌توانند از بین فهرست رو به رشدی از بهترین مدل‌های فونداسیون انتخاب کنند. پزشکان ML می توانند مدل های پایه را به صورت اختصاصی به کار گیرند آمازون SageMaker نمونه هایی در یک محیط جدا شده از شبکه، و سفارشی کردن مدل ها با استفاده از SageMaker برای آموزش و استقرار مدل.

اکنون می‌توانید Mistral 7B را با چند کلیک کشف و اجرا کنید Amazon SageMaker Studio یا به صورت برنامه نویسی از طریق SageMaker Python SDK، به شما امکان می دهد عملکرد مدل و کنترل های MLOps را با ویژگی های SageMaker مانند خطوط لوله آمازون SageMaker, دیباگر Amazon SageMaker، یا سیاهههای مربوط به کانتینر. این مدل در یک محیط امن AWS و تحت کنترل های VPC شما مستقر شده است و به اطمینان از امنیت داده ها کمک می کند.

مدل ها را کشف کنید

می‌توانید از طریق SageMaker JumpStart در SageMaker Studio UI و SageMaker Python SDK به مدل‌های پایه Mistral 7B دسترسی پیدا کنید. در این بخش به نحوه کشف مدل ها در SageMaker Studio می پردازیم.

SageMaker Studio یک محیط توسعه یکپارچه (IDE) است که یک رابط بصری مبتنی بر وب را فراهم می کند که در آن می توانید به ابزارهای ساخته شده برای انجام تمام مراحل توسعه ML، از آماده سازی داده ها تا ساخت، آموزش، و استقرار مدل های ML خود دسترسی داشته باشید. برای جزئیات بیشتر در مورد نحوه شروع و راه اندازی SageMaker Studio، مراجعه کنید Amazon SageMaker Studio.

در SageMaker Studio، می‌توانید به SageMaker JumpStart دسترسی داشته باشید که شامل مدل‌های از پیش آموزش‌دیده، نوت‌بوک‌ها و راه‌حل‌های از پیش ساخته شده است. راه حل های از پیش ساخته شده و خودکار.

از صفحه فرود SageMaker JumpStart، می توانید راه حل ها، مدل ها، نوت بوک ها و منابع دیگر را جستجو کنید. شما می‌توانید Mistral 7B را در آن پیدا کنید مدل های بنیاد: تولید متن چرخ فلک.

شما همچنین می توانید مدل های دیگر را با انتخاب پیدا کنید تمام مدل های متنی را کاوش کنید یا جستجوی «Mistral»

می‌توانید کارت مدل را برای مشاهده جزئیات مدل مانند مجوز، داده‌های مورد استفاده برای آموزش و نحوه استفاده انتخاب کنید. همچنین دو دکمه پیدا خواهید کرد، گسترش و نوت بوک را باز کنید، که به شما در استفاده از مدل کمک می کند (عکس صفحه زیر نشان می دهد گسترش گزینه).

استقرار مدلها

استقرار با انتخاب شما شروع می شود گسترش. از طرف دیگر، می‌توانید از طریق دفترچه یادداشت مثالی که هنگام انتخاب نشان داده می‌شود، استفاده کنید نوت بوک را باز کنید. دفترچه یادداشت نمونه راهنمایی سرتاسری در مورد نحوه استقرار مدل برای استنتاج و پاکسازی منابع ارائه می دهد.

برای استقرار با استفاده از نوت بوک، با انتخاب مدل Mistral 7B، مشخص شده توسط model_id. می توانید هر یک از مدل های انتخاب شده را با کد زیر در SageMaker مستقر کنید:

from sagemaker.jumpstart.model import JumpStartModel model = JumpStartModel(model_id="huggingface-llm-mistral-7b-instruct")
predictor = model.deploy()

این مدل را با پیکربندی‌های پیش‌فرض، از جمله نوع نمونه پیش‌فرض (ml.g5.2xlarge) و پیکربندی‌های پیش‌فرض VPC، در SageMaker مستقر می‌کند. شما می توانید این تنظیمات را با تعیین مقادیر غیر پیش فرض در آن تغییر دهید JumpStartModel. پس از استقرار، می توانید استنتاج را در برابر نقطه پایانی مستقر شده از طریق پیش بینی SageMaker اجرا کنید:

payload = {"inputs": "<s>[INST] Hello! [/INST]"}
predictor.predict(payload)

بهینه سازی پیکربندی استقرار

مدل‌های میسترال از سرویس مدل استنتاج نسل متن (TGI نسخه 1.1) استفاده می‌کنند. هنگام استقرار مدل‌ها با ظرف یادگیری عمیق TGI (DLC)، می‌توانید انواع مختلفی را پیکربندی کنید آرگومان های پرتاب کننده از طریق متغیرهای محیطی هنگام استقرار نقطه پایانی خود. SageMaker JumpStart برای پشتیبانی از طول زمینه 8,000 توکن مدل های Mistral 7B، برخی از این پارامترها را به طور پیش فرض پیکربندی کرده است: ما تنظیم کردیم MAX_INPUT_LENGTH و MAX_TOTAL_TOKENS به ترتیب به 8191 و 8192 رسید. با بررسی شی مدل خود می توانید لیست کامل را مشاهده کنید:

print(model.env)

به طور پیش فرض، SageMaker JumpStart کاربران همزمان را از طریق متغیر محیطی گیر نمی کند. MAX_CONCURRENT_REQUESTS کوچکتر از مقدار پیش‌فرض TGI 128. دلیل آن این است که برخی از کاربران ممکن است بارهای کاری معمولی با طول زمینه محموله کوچک داشته باشند و خواهان همزمانی بالا باشند. توجه داشته باشید که SageMaker TGI DLC از چندین کاربر همزمان از طریق Rolling Batch پشتیبانی می کند. هنگام استقرار نقطه پایانی خود برای برنامه خود، ممکن است در نظر بگیرید که آیا باید clamp کنید یا خیر MAX_TOTAL_TOKENS or MAX_CONCURRENT_REQUESTS قبل از استقرار برای ارائه بهترین عملکرد برای حجم کاری:

model.env["MAX_CONCURRENT_REQUESTS"] = "4"

در اینجا، نشان می‌دهیم که چگونه عملکرد مدل ممکن است برای بار کاری نقطه پایانی معمولی شما متفاوت باشد. در جداول زیر می توانید مشاهده کنید که پرس و جوهای کوچک (128 کلمه ورودی و 128 نشانه خروجی) در تعداد زیادی از کاربران همزمان کاملاً کارآمد هستند و به توان عملیاتی توکن در مرتبه 1,000 توکن در ثانیه می رسند. با این حال، وقتی تعداد کلمات ورودی به 512 کلمه ورودی افزایش می‌یابد، نقطه پایانی ظرفیت دسته‌ای خود را اشباع می‌کند - تعداد درخواست‌های همزمان مجاز به پردازش همزمان - که منجر به یک فلات توان و کاهش تاخیر قابل توجهی می‌شود که از حدود 16 کاربر همزمان شروع می‌شود. در نهایت، هنگام پرس و جو از نقطه پایانی با زمینه های ورودی بزرگ (به عنوان مثال، 6,400 کلمه) به طور همزمان توسط چندین کاربر همزمان، این پلاتو گذرگاه نسبتاً سریع رخ می دهد، تا جایی که حساب SageMaker شما شروع به مواجهه با محدودیت های زمان پاسخ 60 ثانیه ای برای درخواست های بیش از حد شما می کند. .

. توان عملیاتی (توکن/ها)
کاربران همزمان 1 2 4 8 16 32 64 128
مدل نوع نمونه کلمات ورودی توکن های خروجی .
mistral-7b-instruct ml.g5.2xlarge 128 128 30 54 89 166 287 499 793 1030
512 128 29 50 80 140 210 315 383 458
6400 128 17 25 30 35 - - - -
. تأخیر p50 (ms/token)
کاربران همزمان 1 2 4 8 16 32 64 128
مدل نوع نمونه کلمات ورودی توکن های خروجی .
mistral-7b-instruct ml.g5.2xlarge 128 128 32 33 34 36 41 46 59 88
512 128 34 36 39 43 54 71 112 213
6400 128 57 71 98 154 - - - -

استنتاج و اعلانات مثال

Mistral 7B

می‌توانید با یک مدل پایه Mistral 7B مانند هر مدل استاندارد تولید متن تعامل کنید، که در آن مدل یک توالی ورودی را پردازش می‌کند و کلمات بعدی پیش‌بینی‌شده در دنباله را خروجی می‌دهد. در زیر یک مثال ساده با یادگیری چند شات است، که در آن مدل با چندین مثال ارائه شده و پاسخ نمونه نهایی با دانش متنی این مثال‌های قبلی تولید می‌شود:

> Input
Tweet: "I get sad when my phone battery dies."
Sentiment: Negative
###
Tweet: "My day has been :+1:"
Sentiment: Positive
###
Tweet: "This is the link to the article"
Sentiment: Neutral
###
Tweet: "This new music video was incredibile"
Sentiment: > Output Positive

دستور Mistral 7B

نسخه تنظیم‌شده با دستورالعمل Mistral دستورالعمل‌های قالب‌بندی شده را می‌پذیرد که در آن نقش‌های مکالمه باید با یک فرمان کاربر شروع شود و بین کاربر و دستیار جایگزین شود. یک فرمان ساده کاربر ممکن است به شکل زیر باشد:

<s>[INST] {user_prompt} [/INST]

یک اعلان چند دور به شکل زیر خواهد بود:

<s>[INST] {user_prompt_1} [/INST] {assistant_response_1} </s><s>[INST] {user_prompt_1} [/INST]

این الگو برای هر چند نوبت در مکالمه تکرار می شود.

در بخش‌های بعدی، نمونه‌هایی را با استفاده از مدل Mistral 7B Instruct بررسی می‌کنیم.

بازیابی دانش

مثال زیر نمونه ای از بازیابی دانش است:

> Input
<s>[INST] Which country has the most natural lakes? Answer with only the country name. [/INST] > Output
1. Canada

پاسخ به سوال زمینه بزرگ

برای نشان دادن نحوه استفاده از این مدل برای پشتیبانی از طول زمینه ورودی بزرگ، مثال زیر بخشی را با عنوان "Rats" توسط رابرت سالیوان تعبیه می کند.مرجع)، از آزمون درک مطلب خواندنی هنرهای زبان انگلیسی کلاس 10 MCAS به دستورالعمل اعلان ورودی وارد می شود و از مدل یک سوال هدایت شده در مورد متن می پرسد:

> Input
<s>[INST] A rat is a rodent, the most common mammal in the world. Rattus norvegicus is one of the approximately four hundred different kinds of rodents, and it is known by many names, each of which describes a trait or a perceived trait or sometimes a habitat: the earth rat, the roving rat, the barn rat, the fi eld rat, the migratory rat, the house rat, the sewer rat, the water rat, the wharf rat, the alley rat, the gray rat, the brown rat, and the common rat. The average brown rat is large and stocky; it grows to be approximately sixteen inches long from its nose to its tail—the size of a large adult human male’s foot—and weighs about a pound, though brown rats have been measured by scientists and exterminators at twenty inches and up to two pounds. The brown rat is sometimes confused with the black rat, or Rattus rattus, which is smaller and once inhabited New York City and all of the cities of America but, since Rattus norvegicus pushed it out, is now relegated to a minor role. (The two species still survive alongside each other in some Southern coastal cities and on the West Coast, in places like Los Angeles, for example, where the black rat lives in attics and palm trees.) The black rat is always a very dark gray, almost black, and the brown rat is gray or brown, with a belly that can be light gray, yellow, or even a pure-seeming white. One spring, beneath the Brooklyn Bridge, I saw a red-haired brown rat that had been run over by a car. Both pet rats and laboratory rats are Rattus norvegicus, but they are not wild and therefore, I would emphasize, not the subject of this book. Sometimes pet rats are called fancy rats. But if anyone has picked up this book to learn about fancy rats, then they should put this book down right away; none of the rats mentioned herein are at all fancy. Rats are nocturnal, and out in the night the brown rat’s eyes are small and black and shiny; when a fl ashlight shines into them in the dark, the eyes of a rat light up like the eyes of a deer. Though it forages* in darkness, the brown rat has poor eyesight. It makes up for this with, fi rst of all, an excellent sense of smell. . . . They have an excellent sense of taste, detecting the most minute amounts of poison, down to one part per million. A brown rat has strong feet, the two front paws each equipped with four clawlike nails, the rear paws even longer and stronger. It can run and climb with squirrel-like agility. It is an excellent swimmer, surviving in rivers and bays, in sewer streams and toilet bowls. The brown rat’s teeth are yellow, the front two incisors being especially long and sharp, like buckteeth. When the brown rat bites, its front two teeth spread apart. When it gnaws, a fl ap of skin plugs the space behind its incisors. Hence, when the rat gnaws on indigestible materials—concrete or steel, for example—the shavings don’t go down the rat’s throat and kill it. Its incisors grow at a rate of fi ve inches per year. Rats always gnaw, and no one is certain why—there are few modern rat studies. It is sometimes erroneously stated that the rat gnaws solely to limit the length of its incisors, which would otherwise grow out of its head, but this is not the case: the incisors wear down naturally. In terms of hardness, the brown rat’s teeth are stronger than aluminum, copper, lead, and iron. They are comparable to steel. With the alligator-like structure of their jaws, rats can exert a biting pressure of up to seven thousand pounds per square inch. Rats, like mice, seem to be attracted to wires—to utility wires, computer wires, wires in vehicles, in addition to gas and water pipes. One rat expert theorizes that wires may be attractive to rats because of their resemblance to vines and the stalks of plants; cables are the vines of the city. By one estimate, 26 percent of all electric-cable breaks and 18 percent of all phone-cable disruptions are caused by rats. According to one study, as many as 25 percent of all fi res of unknown origin are rat-caused. Rats chew electrical cables. Sitting in a nest of tattered rags and newspapers, in the fl oorboards of an old tenement, a rat gnaws the head of a match—the lightning in the city forest. When it is not gnawing or feeding on trash, the brown rat digs. Anywhere there is dirt in a city, brown rats are likely to be digging—in parks, in fl owerbeds, in little dirt-poor backyards. They dig holes to enter buildings and to make nests. Rat nests can be in the floorboards of apartments, in the waste-stuffed corners of subway stations, in sewers, or beneath old furniture in basements. “Cluttered and unkempt alleyways in cities provide ideal rat habitat, especially those alleyways associated with food-serving establishments,” writes Robert Corrigan in Rodent Control, a pest control manual. “Alley rats can forage safely within the shadows created by the alleyway, as well as quickly retreat to the safety of cover in these narrow channels.” Often, rats burrow under concrete sidewalk slabs. Entrance to a typical under-the-sidewalk rat’s nest is gained through a two-inch-wide hole—their skeletons collapse and they can squeeze into a hole as small as three quarters of an inch wide, the average width of their skull. This tunnel then travels about a foot down to where it widens into a nest or den. The den is lined with soft debris, often shredded plastic garbage or shopping bags, but sometimes even grasses or plants; some rat nests have been found stuffed with the gnawed shavings of the wood-based, spring-loaded snap traps that are used in attempts to kill them. The back of the den then narrows into a long tunnel that opens up on another hole back on the street. This second hole is called a bolt hole; it is an emergency exit. A bolt hole is typically covered lightly with dirt or trash—camoufl age. Sometimes there are networks of burrows, which can stretch beneath a few concrete squares on a sidewalk, or a number of backyards, or even an entire city block—when Rattus norvegicus fi rst came to Selkirk, England, in 1776, there were so many burrows that people feared the town might sink. Rats can also nest in basements, sewers, manholes, abandoned pipes of any kind, fl oorboards, or any hole or depression. “Often,” Robert Corrigan writes, “‘city rats’ will live unbeknownst to people right beneath their feet.” Rats also inhabit subways, as most people in New York City and any city with a subway system are well aware. Every once in a while, there are reports of rats boarding trains, but for the most part rats stay on the tracks—subway workers I have talked to refer to rats as “track rabbits.” People tend to think that the subways are fi lled with rats, but in fact rats are not everywhere in the system; they live in the subways according to the supply of discarded human food and sewer leaks. Sometimes, rats use the subway purely for nesting purposes; they fi nd ways through the walls of the subway stations leading from the tracks to the restaurants and stores on the street—the vibrations of subway trains tend to create rat-size cracks and holes. Many subway rats tend to live near stations that are themselves near fast-food restaurants. At the various subway stations near Herald Square, for example, people come down from the streets and throw the food that they have not eaten onto the tracks, along with newspapers and soda bottles and, I have noticed, thousands of nolonger-charged AA batteries, waiting to leak acid. The rats eat freely from the waste and sit at the side of the little streams of creamy brown sewery water that fl ows between the rails. They sip the water the way rats do, either with their front paws or by scooping it up with their incisors. What is the most likely reason the author states, "cables are the vines of the city"? [/INST] > Output
1. The author states that rats are attracted to wires, such as utility wires, computer wires, and vehicle wires, which may be due to their resemblance to vines and the stalks of plants.

ریاضیات و استدلال

مدل‌های Mistral همچنین نقاط قوت را در دقت ریاضیات گزارش می‌کنند. میسترال می‌تواند درکی مانند منطق ریاضی زیر را ارائه دهد:

> Input
<s>[INST] I bought an ice cream for 6 kids. Each cone was $1.25 and I paid with a $10 bill. How many dollars did I get back? Explain first before answering. [/INST] > Output
1. First, let's figure out how much the ice cream cost in total. Since each cone was $1.25 and there were 6 kids, the total cost would be: Total cost = Number of cones * Cost per cone
Total cost = 6 * $1.25
Total cost = $7.50 2. Next, we'll subtract the total cost from the amount paid ($10) to find out how much money was returned: Money returned = Amount paid - Total cost
Money returned = $10 - $7.50
Money returned = $2.50 So, you got back $2.50 after buying the ice cream for the 6 kids.

برنامه نویسی

در زیر نمونه ای از اعلان کدنویسی آمده است:

> Input
<s>[INST] In Bash, how do I list all text files in the current directory (excluding subdirectories) that have been modified in the last month? [/INST] > Output
1. Use the `find` command to search for text files in the current directory (excluding subdirectories) that have been modified in the last month. The `-type f` option specifies that we only want to search for files, not directories. The `-name "*.txt"` option specifies that we only want to search for files with the `.txt` extension. The `-mtime -30` option specifies that we only want to search for files that have been modified in the last 30 days (1 month). ```bash
find . -type f -name "*.txt" -mtime -30
``` This command will list all text files in the current directory (excluding subdirectories) that have been modified in the last month.

پاک کردن

پس از اتمام اجرای نوت بوک، مطمئن شوید که تمام منابعی را که در این فرآیند ایجاد کرده اید حذف کرده اید تا صورتحساب شما متوقف شود. از کد زیر استفاده کنید:

predictor.delete_model()
predictor.delete_endpoint()

نتیجه

در این پست به شما نشان دادیم که چگونه می‌توان با Mistral 7B در SageMaker Studio شروع کرد و مدل را برای استنباط به کار برد. از آنجایی که مدل های فونداسیون از قبل آموزش دیده اند، می توانند به کاهش هزینه های آموزش و زیرساخت کمک کنند و سفارشی سازی را برای موارد استفاده شما امکان پذیر کنند. بازدید کنید Amazon SageMaker JumpStart اکنون برای شروع

منابع


درباره نویسنده

دکتر کایل اولریش یک دانشمند کاربردی با تیم آمازون SageMaker JumpStart است. علایق تحقیقاتی او شامل الگوریتم های یادگیری ماشین مقیاس پذیر، بینایی کامپیوتر، سری های زمانی، ناپارامتریک های بیزی و فرآیندهای گاوسی است. دکترای او از دانشگاه دوک است و مقالاتی در NeurIPS، Cell و Neuron منتشر کرده است.

دکتر آشیش ختان یک دانشمند ارشد کاربردی با Amazon SageMaker JumpStart است و به توسعه الگوریتم های یادگیری ماشین کمک می کند. او دکترای خود را از دانشگاه ایلینویز Urbana-Champaign گرفت. او یک محقق فعال در یادگیری ماشین و استنتاج آماری است و مقالات زیادی در کنفرانس های NeurIPS، ICML، ICLR، JMLR، ACL و EMNLP منتشر کرده است.

ویوک سینگ مدیر محصول با Amazon SageMaker JumpStart است. او بر روی قادر ساختن مشتریان به SageMaker JumpStart تمرکز می کند تا سفر ML خود را برای ساختن برنامه های کاربردی هوش مصنوعی ساده و تسریع بخشند.

روی آللا یک معمار ارشد راه حل های تخصصی AI/ML در AWS مستقر در مونیخ، آلمان است. روی به مشتریان AWS - از استارت‌آپ‌های کوچک گرفته تا شرکت‌های بزرگ - کمک می‌کند تا مدل‌های زبان بزرگ را به‌طور کارآمد در AWS آموزش داده و به کار گیرند. روی مشتاق مشکلات بهینه‌سازی محاسباتی و بهبود عملکرد بارهای کاری هوش مصنوعی است.

نقطه_img

جدیدترین اطلاعات

نقطه_img

چت با ما

سلام! چگونه می توانم به شما کمک کنم؟