Zephyrnet Logosu

Mistral AI'nin Mistral 7B temel modelleri artık Amazon SageMaker JumpStart'ta mevcut | Amazon Web Hizmetleri

Tarih:

Bugün, Mistral AI tarafından geliştirilen Mistral 7B temel modellerinin müşterilerimizin kullanımına sunulduğunu duyurmanın heyecanını yaşıyoruz. Amazon SageMaker Hızlı Başlangıç çıkarımı çalıştırmak için tek tıklamayla dağıtmak. 7 milyar parametreyle Mistral 7B kolaylıkla özelleştirilebilir ve hızlı bir şekilde devreye alınabilir. Bu modeli, ML'ye hızla başlayabilmeniz için algoritmalara ve modellere erişim sağlayan bir makine öğrenimi (ML) merkezi olan SageMaker JumpStart ile deneyebilirsiniz. Bu yazıda Mistral 7B modelinin nasıl keşfedilip konuşlandırılacağını açıklıyoruz.

Mistral 7B Nedir?

Mistral 7B, Mistral AI tarafından geliştirilen, İngilizce metin ve kod oluşturma yeteneklerini destekleyen bir temel modeldir. Metin özetleme, sınıflandırma, metin tamamlama ve kod tamamlama gibi çeşitli kullanım durumlarını destekler. Mistral AI, modelin kolay özelleştirilebilirliğini göstermek amacıyla, sohbet kullanım durumları için, halka açık çeşitli konuşma veri kümeleri kullanılarak ince ayar yapılan bir Mistral 7B Instruct modeli de yayınladı.

Mistral 7B bir dönüştürücü modelidir ve daha hızlı çıkarım (düşük gecikme) elde etmek ve daha uzun dizileri işlemek için gruplandırılmış sorgu dikkatini ve kayan pencere dikkatini kullanır. Grup sorgu dikkati, çoklu sorgu dikkatine yakın çıktı kalitesi ve çoklu sorgu dikkatiyle karşılaştırılabilir hız elde etmek için çoklu sorgu ve çok kafalı dikkati birleştiren bir mimaridir. Kayar pencere dikkati, bağlam uzunluğunu artırmak için pencere boyutunun ötesinde geçmişe katılmak için bir transformatörün yığılmış katmanlarını kullanır. Mistral 7B, 8,000 jetonluk bağlam uzunluğuna sahiptir, düşük gecikme süresi ve yüksek verim gösterir ve daha büyük model alternatifleriyle karşılaştırıldığında güçlü bir performansa sahiptir ve 7B model boyutunda düşük bellek gereksinimleri sağlar. Model izin kapsamında kullanıma sunuldu Apache 2.0 lisansı, kısıtlama olmaksızın kullanım için.

SageMaker JumpStart nedir?

SageMaker JumpStart ile makine öğrenimi uygulayıcıları, en iyi performans gösteren temel modellerin giderek büyüyen listesinden seçim yapabilir. ML uygulayıcıları temel modelleri özel olarak dağıtabilir Amazon Adaçayı Yapıcı ağdan izole edilmiş bir ortamda örnekler oluşturun ve model eğitimi ve dağıtımı için SageMaker'ı kullanarak modelleri özelleştirin.

Artık Mistral 7B'yi birkaç tıklamayla keşfedebilir ve konuşlandırabilirsiniz. Amazon SageMaker Stüdyosu veya SageMaker Python SDK aracılığıyla programlı olarak, SageMaker özellikleriyle model performansı ve MLOps kontrolleri türetmenizi sağlar. Amazon SageMaker Ardışık Düzenleri, Amazon SageMaker Hata Ayıklayıcısıveya konteyner günlükleri. Model, AWS güvenli ortamında ve VPC kontrolleriniz altında dağıtılarak veri güvenliğinin sağlanmasına yardımcı olur.

Modelleri keşfedin

Mistral 7B temel modellerine, SageMaker Studio kullanıcı arayüzündeki ve SageMaker Python SDK'sındaki SageMaker JumpStart aracılığıyla erişebilirsiniz. Bu bölümde SageMaker Studio'daki modelleri nasıl keşfedeceğimizi ele alıyoruz.

SageMaker Studio, verileri hazırlamaktan makine öğrenimi modellerinizi oluşturmaya, eğitmeye ve dağıtmaya kadar tüm makine öğrenimi geliştirme adımlarını gerçekleştirmek için amaca yönelik oluşturulmuş araçlara erişebileceğiniz tek bir web tabanlı görsel arabirim sağlayan entegre bir geliştirme ortamıdır (IDE). Nasıl başlayacağınız ve SageMaker Studio'yu nasıl kuracağınız hakkında daha fazla bilgi için bkz. Amazon SageMaker Stüdyosu.

SageMaker Studio'da, önceden eğitilmiş modeller, dizüstü bilgisayarlar ve önceden oluşturulmuş çözümler içeren SageMaker JumpStart'a şu adresten erişebilirsiniz: Önceden oluşturulmuş ve otomatikleştirilmiş çözümler.

SageMaker JumpStart açılış sayfasından çözümlere, modellere, not defterlerine ve diğer kaynaklara göz atabilirsiniz. Mistral 7B'yi şurada bulabilirsiniz: Temel Modelleri: Metin Üretimi atlıkarınca

Diğer model çeşitlerini de tercih ederek bulabilirsiniz. Tüm Metin Modellerini keşfedin veya "Mistral"ı aramak.

Lisans, eğitim için kullanılan veriler ve nasıl kullanılacağı gibi modelle ilgili ayrıntıları görüntülemek için model kartını seçebilirsiniz. Ayrıca iki düğme bulacaksınız, Sürüş ve Not defterini açmodeli kullanmanıza yardımcı olacaktır (aşağıdaki ekran görüntüsünde Sürüş seçenek).

Modelleri dağıtmak

Dağıtım siz seçtiğinizde başlar Sürüş. Alternatif olarak, seçtiğinizde görünen örnek not defteri aracılığıyla da dağıtım yapabilirsiniz. Not defterini aç. Örnek not defteri, modelin çıkarım için nasıl dağıtılacağı ve kaynakların nasıl temizleneceği konusunda uçtan uca rehberlik sağlar.

Dizüstü bilgisayar kullanarak dağıtım yapmak için, Mistral 7B modelini seçerek başlıyoruz. model_id. Seçili modellerden herhangi birini SageMaker'da aşağıdaki kodla konuşlandırabilirsiniz:

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

Bu, modeli SageMaker'da, varsayılan örnek türü (ml.g5.2xlarge) ve varsayılan VPC yapılandırmaları dahil olmak üzere varsayılan yapılandırmalarla dağıtır. Varsayılan olmayan değerleri belirterek bu yapılandırmaları değiştirebilirsiniz. HızlıBaşlangıçModeli. Dağıtıldıktan sonra, SageMaker öngörücü aracılığıyla dağıtılan uç noktaya karşı çıkarım çalıştırabilirsiniz:

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

Dağıtım yapılandırmasını optimize etme

Mistral modelleri, Metin Üretme Çıkarımı (TGI sürüm 1.1) model hizmetini kullanır. Modelleri TGI derin öğrenme kapsayıcısı (DLC) ile dağıtırken, çeşitli yapılandırmaları yapılandırabilirsiniz. başlatıcı argümanları Uç noktanızı dağıtırken ortam değişkenleri aracılığıyla. Mistral 8,000B modellerinin 7 jetonluk bağlam uzunluğunu desteklemek için SageMaker JumpStart bu parametrelerden bazılarını varsayılan olarak yapılandırmıştır: MAX_INPUT_LENGTH ve MAX_TOTAL_TOKENS sırasıyla 8191 ve 8192'ye. Model nesnenizi inceleyerek tam listeyi görüntüleyebilirsiniz:

print(model.env)

Varsayılan olarak SageMaker JumpStart, ortam değişkeni aracılığıyla eşzamanlı kullanıcıları sıkıştırmaz MAX_CONCURRENT_REQUESTS TGI varsayılan değeri olan 128'den daha küçüktür. Bunun nedeni, bazı kullanıcıların küçük veri yükü bağlam uzunluklarına sahip tipik iş yüklerine sahip olabilmesi ve yüksek eşzamanlılık istemesidir. SageMaker TGI DLC'nin sürekli toplu iş yoluyla birden fazla eşzamanlı kullanıcıyı desteklediğini unutmayın. Uygulamanız için uç noktanızı dağıtırken, kelepçelemeniz gerekip gerekmediğini düşünebilirsiniz. MAX_TOTAL_TOKENS or MAX_CONCURRENT_REQUESTS İş yükünüz için en iyi performansı sağlamak amacıyla dağıtımdan önce:

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

Burada, tipik uç nokta iş yükünüz için model performansının nasıl farklılık gösterebileceğini gösteriyoruz. Aşağıdaki tablolarda, küçük boyutlu sorguların (128 giriş kelimesi ve 128 çıkış jetonu) çok sayıda eşzamanlı kullanıcı altında oldukça performanslı olduğunu ve saniyede 1,000 jeton civarında jeton verimine ulaştığını gözlemleyebilirsiniz. Bununla birlikte, giriş sözcüklerinin sayısı 512 giriş sözcüğüne yükseldikçe uç nokta, toplu işleme kapasitesini (aynı anda işlenmesine izin verilen eşzamanlı isteklerin sayısı) doyurur ve bu da yaklaşık 16 eşzamanlı kullanıcıdan başlayarak bir üretim platosuna ve önemli gecikme bozulmalarına neden olur. Son olarak, büyük giriş bağlamlarına (örneğin, 6,400 kelime) sahip uç nokta birden fazla eş zamanlı kullanıcı tarafından eş zamanlı olarak sorgulandığında, bu verim platosu nispeten hızlı bir şekilde ortaya çıkar ve SageMaker hesabınızın, aşırı yüklenmiş istekleriniz için 60 saniyelik yanıt zaman aşımı sınırlarıyla karşılaşmaya başlayacağı noktaya gelir. .

. verim (jeton/s)
eşzamanlı kullanıcılar 1 2 4 8 16 32 64 128
model örnek türü kelimeleri girin çıktı belirteçleri .
mistral-7b-talimat 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 gecikmesi (ms/jeton)
eşzamanlı kullanıcılar 1 2 4 8 16 32 64 128
model örnek türü kelimeleri girin çıktı belirteçleri .
mistral-7b-talimat 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 - - - -

Çıkarım ve örnek istemler

Mistral 7B

Herhangi bir standart metin oluşturma modeli gibi temel bir Mistral 7B modeliyle etkileşime girebilirsiniz; burada model bir giriş dizisini işler ve dizideki tahmin edilen sonraki kelimeleri çıkarır. Aşağıda, modelin çeşitli örneklerle sağlandığı ve son örnek yanıtının bu önceki örneklerin bağlamsal bilgisiyle oluşturulduğu, çok adımlı öğrenmeye ilişkin basit bir örnek verilmiştir:

> 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 talimatı

Mistral'in talimat ayarlı sürümü, konuşma rollerinin bir kullanıcı istemiyle başlaması ve kullanıcı ile asistan arasında geçiş yapması gereken biçimlendirilmiş talimatları kabul eder. Basit bir kullanıcı istemi aşağıdaki gibi görünebilir:

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

Çok dönüşlü bir istem aşağıdaki gibi görünecektir:

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

Bu kalıp, konuşmada ne kadar çok dönüş olursa olsun tekrarlanır.

Aşağıdaki bölümlerde Mistral 7B Instruct modelini kullanan bazı örnekleri inceliyoruz.

Bilgiye erişim

Aşağıda bilgi erişimine bir örnek verilmiştir:

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

Geniş bağlamlı soru yanıtlama

Büyük girdi bağlamı uzunluklarını desteklemek için bu modelin nasıl kullanılacağını göstermek amacıyla aşağıdaki örnekte Robert Sullivan'ın "Rats" başlıklı bir pasajı yer almaktadır (referans), MCAS 10. Sınıf İngiliz Dili Sanatları Okuduğunu Anlama testinden giriş istemi talimatına girer ve modele metin hakkında yönlendirilmiş bir soru sorar:

> 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.

Matematik ve akıl yürütme

Mistral modelleri aynı zamanda matematik doğruluğundaki güçlü yönleri de rapor etmektedir. Mistral aşağıdaki matematik mantığına benzer bir anlayış sağlayabilir:

> 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.

kodlama

Aşağıda bir kodlama istemi örneği verilmiştir:

> 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.

Temizlemek

Not defterini çalıştırmayı tamamladıktan sonra, faturalandırmanın durdurulması için süreçte oluşturduğunuz tüm kaynakları sildiğinizden emin olun. Aşağıdaki kodu kullanın:

predictor.delete_model()
predictor.delete_endpoint()

Sonuç

Bu yazıda size SageMaker Studio'da Mistral 7B'yi kullanmaya nasıl başlayacağınızı ve modeli çıkarım için nasıl dağıtacağınızı gösterdik. Temel modeller önceden eğitildiğinden, eğitim ve altyapı maliyetlerinin azaltılmasına yardımcı olabilir ve kullanım durumunuza göre özelleştirmeye olanak sağlayabilir. Ziyaret etmek Amazon SageMaker Hızlı Başlangıç şimdi başlamak için.

Kaynaklar


Yazarlar Hakkında

Doktor Kyle Ulrich Amazon SageMaker JumpStart ekibinde bir Uygulamalı Bilim Adamıdır. Araştırma ilgi alanları arasında ölçeklenebilir makine öğrenimi algoritmaları, bilgisayar görüşü, zaman serileri, Bayes parametrik olmayanları ve Gauss süreçleri yer alır. Doktorası Duke Üniversitesi'ndendir ve NeurIPS, Cell ve Neuron'da yayınlanmış makaleleri vardır.

Ashish Khetan Amazon SageMaker JumpStart'ta Kıdemli Uygulamalı Bilim Adamıdır ve makine öğrenimi algoritmalarının geliştirilmesine yardımcı olur. Doktora derecesini University of Illinois Urbana-Champaign'den almıştır. Makine öğrenimi ve istatistiksel çıkarım alanlarında aktif bir araştırmacıdır ve NeurIPS, ICML, ICLR, JMLR, ACL ve EMNLP konferanslarında birçok makale yayınlamıştır.

Vivek Singh Amazon SageMaker JumpStart'ta ürün yöneticisidir. Müşterilerin, üretken yapay zeka uygulamaları oluşturmaya yönelik makine öğrenimi yolculuklarını basitleştirmek ve hızlandırmak için SageMaker JumpStart'ı kullanmalarına olanak sağlamaya odaklanıyor.

Roy Allela Münih, Almanya merkezli AWS'de Kıdemli Yapay Zeka/ML Uzmanı Çözüm Mimarıdır. Roy, küçük startup'lardan büyük işletmelere kadar AWS müşterilerinin büyük dil modellerini AWS üzerinde verimli bir şekilde eğitmesine ve devreye almasına yardımcı olur. Roy, hesaplamalı optimizasyon sorunları ve yapay zeka iş yüklerinin performansını iyileştirme konusunda tutkulu.

spot_img

En Son İstihbarat

spot_img