이제 Amazon SageMaker JumpStart에서 Mixtral-8x7B를 사용할 수 있습니다 | 아마존 웹 서비스

이제 Amazon SageMaker JumpStart에서 Mixtral-8x7B를 사용할 수 있습니다 | 아마존 웹 서비스

오늘 우리는 다음과 같은 소식을 발표하게 되어 기쁘게 생각합니다. 믹스트랄-8x7B Mistral AI가 개발한 LLM(대형 언어 모델)을 통해 고객이 사용할 수 있습니다. Amazon SageMaker 점프스타트 추론 실행을 위해 한 번의 클릭으로 배포합니다. Mixtral-8x7B LLM은 피드포워드 레이어당 7명의 전문가가 있는 8억 매개변수 백본을 기반으로 하는 사전 훈련된 전문가 모델의 희소 혼합입니다. ML을 빠르게 시작할 수 있도록 알고리즘과 모델에 대한 액세스를 제공하는 기계 학습(ML) 허브인 SageMaker JumpStart로 이 모델을 시험해 볼 수 있습니다. 이 게시물에서는 Mixtral-7xXNUMXB 모델을 검색하고 배포하는 방법을 안내합니다.

Mixtral-8x7B 란 무엇입니까?

Mixtral-8x7B는 Mistral AI가 개발한 기반 모델로, 코드 생성 기능을 통해 영어, 프랑스어, 독일어, 이탈리아어 및 스페인어 텍스트를 지원합니다. 텍스트 요약, 분류, 텍스트 완성, 코드 완성 등 다양한 사용 사례를 지원합니다. 채팅 모드에서는 잘 작동합니다. 모델의 간단한 사용자 정의 가능성을 입증하기 위해 Mistral AI는 공개적으로 사용 가능한 다양한 대화 데이터 세트를 사용하여 미세 조정된 채팅 사용 사례를 위한 Mixtral-8x7B-instruct 모델도 출시했습니다. Mixtral 모델은 최대 32,000개 토큰의 긴 컨텍스트 길이를 갖습니다.

Mixtral-8x7B는 이전 최첨단 모델에 비해 상당한 성능 향상을 제공합니다. 전문가 아키텍처가 드물게 혼합되어 테스트된 자연어 처리(NLP) 벤치마크 9개 중 12개에서 더 나은 성능 결과를 얻을 수 있습니다. 미스트랄 AI. Mixtral은 크기가 최대 10배인 모델의 성능과 일치하거나 이를 능가합니다. 토큰당 극히 일부 매개변수만 활용함으로써 동일한 크기의 조밀한 모델에 비해 더 빠른 추론 속도와 더 낮은 계산 비용을 달성합니다. 예를 들어 총 46.7억 개의 매개변수가 있지만 토큰당 사용되는 매개변수는 12.9억 개에 불과합니다. 고성능, 다국어 지원 및 계산 효율성의 조합으로 Mixtral-8x7B는 NLP 애플리케이션을 위한 매력적인 선택이 됩니다.

이 모델은 제한 없이 사용할 수 있도록 허용되는 Apache 2.0 라이센스에 따라 제공됩니다.

SageMaker JumpStart란?

SageMaker JumpStart를 사용하면 ML 실무자는 점점 늘어나는 최고 성능의 기초 모델 목록에서 선택할 수 있습니다. ML 실무자는 기초 모델을 전용 모델에 배포할 수 있습니다. 아마존 세이지 메이커 네트워크 격리 환경 내에서 인스턴스를 생성하고, 모델 교육 및 배포를 위해 SageMaker를 사용하여 모델을 사용자 정의합니다.

이제 몇 번의 클릭만으로 Mixtral-8x7B를 검색하고 배포할 수 있습니다. 아마존 세이지 메이커 스튜디오 또는 SageMaker Python SDK를 통해 프로그래밍 방식으로 다음과 같은 SageMaker 기능으로 모델 성능 및 MLOps 컨트롤을 파생할 수 있습니다. Amazon SageMaker 파이프 라인, Amazon SageMaker 디버거또는 컨테이너 로그. 이 모델은 AWS 보안 환경과 VPC 제어에 배포되어 데이터 보안을 보장합니다.

모델 살펴보기

SageMaker Studio UI 및 SageMaker Python SDK의 SageMaker JumpStart를 통해 Mixtral-8x7B 기반 모델에 액세스할 수 있습니다. 이 섹션에서는 SageMaker Studio에서 모델을 검색하는 방법을 살펴보겠습니다.

SageMaker Studio는 데이터 준비에서 ML 모델 구축, 교육 및 배포에 이르기까지 모든 ML 개발 단계를 수행하기 위해 특별히 제작된 도구에 액세스할 수 있는 단일 웹 기반 시각적 인터페이스를 제공하는 통합 개발 환경(IDE)입니다. SageMaker Studio 시작 및 설정 방법에 대한 자세한 내용은 다음을 참조하십시오. 아마존 세이지 메이커 스튜디오.

SageMaker Studio에서는 다음을 선택하여 SageMaker JumpStart에 액세스할 수 있습니다. 점프 시작 탐색 창에서

이제 Amazon SageMaker JumpStart에서 Mixtral-8x7B를 사용할 수 있습니다 | Amazon Web Services PlatoBlockchain 데이터 인텔리전스. 수직 검색. 일체 포함.

SageMaker JumpStart 랜딩 페이지의 검색 상자에서 "Mixtral"을 검색할 수 있습니다. Mixtral 8x7B 및 Mixtral 8x7B Instruct가 표시된 검색 결과가 표시됩니다.

이제 Amazon SageMaker JumpStart에서 Mixtral-8x7B를 사용할 수 있습니다 | Amazon Web Services PlatoBlockchain 데이터 인텔리전스. 수직 검색. 일체 포함.

모델 카드를 선택하면 라이선스, 학습에 사용되는 데이터, 사용 방법 등 모델에 대한 세부 정보를 볼 수 있습니다. 당신은 또한 찾을 수 있습니다 배포 모델을 배포하고 엔드포인트를 생성하는 데 사용할 수 있는 버튼입니다.

이제 Amazon SageMaker JumpStart에서 Mixtral-8x7B를 사용할 수 있습니다 | Amazon Web Services PlatoBlockchain 데이터 인텔리전스. 수직 검색. 일체 포함.

모델 배포

선택하면 배포가 시작됩니다. 배포. 배포가 완료되면 엔드포인트가 생성됩니다. 샘플 추론 요청 페이로드를 전달하거나 SDK를 사용하여 테스트 옵션을 선택하여 엔드포인트를 테스트할 수 있습니다. SDK 사용 옵션을 선택하면 SageMaker Studio의 선호하는 노트북 편집기에서 사용할 수 있는 예제 코드가 표시됩니다.

SDK를 사용하여 배포하려면 먼저 다음에서 지정한 Mixtral-8x7B 모델을 선택합니다. model_id with value huggingface-llm-mixtral-8x7b. 다음 코드를 사용하여 SageMaker에서 선택한 모델을 배포할 수 있습니다. 마찬가지로 자체 모델 ID를 사용하여 Mixtral-8x7B 명령을 배포할 수 있습니다.

from sagemaker.jumpstart.model import JumpStartModel model = JumpStartModel(model_id="huggingface-llm-mixtral-8x7b")
predictor = model.deploy()

그러면 기본 인스턴스 유형 및 기본 VPC 구성을 포함한 기본 구성으로 SageMaker에 모델이 배포됩니다. 기본값이 아닌 값을 지정하여 이러한 구성을 변경할 수 있습니다. JumpStart모델.

배포된 후에는 SageMaker 예측기를 통해 배포된 엔드포인트에 대해 추론을 실행할 수 있습니다.

payload = {"inputs": "Hello!"} predictor.predict(payload)

예제 프롬프트

모델이 입력 시퀀스를 처리하고 시퀀스에서 예측된 다음 단어를 출력하는 표준 텍스트 생성 모델과 마찬가지로 Mixtral-8x7B 모델과 상호 작용할 수 있습니다. 이 섹션에서는 예시 프롬프트를 제공합니다.

코드 생성

이전 예제를 사용하면 다음과 같은 코드 생성 프롬프트를 사용할 수 있습니다.

# Code generation
payload = { "inputs": "Write a program to compute factorial in python:", "parameters": { "max_new_tokens": 200, },
}
predictor.predict(payload)

다음과 같은 결과가 나타납니다.

Input Text: Write a program to compute factorial in python:
Generated Text:
Factorial of a number is the product of all the integers from 1 to that number. For example, factorial of 5 is 1*2*3*4*5 = 120. Factorial of 0 is 1. Factorial of a negative number is not defined. The factorial of a number can be written as n!. For example, 5! = 120. ## Write a program to compute factorial in python ```
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1) print(factorial(5))
``` Output: ```
120
``` ## Explanation: In the above program, we have defined a function called factorial which takes a single argument n. If n is equal to 0, then we return 1. Otherwise, we return n multiplied by the factorial of n-1. We then call the factorial function with the argument 5 and print the result. The output of the program is 120, which is the factorial of 5. ## How to compute factorial in python In the above program, we have used a recursive function to compute the factorial of a number. A recursive function is a function that calls itself. In this case, the factorial function calls itself with the argument n-1. This process continues until n is equal to 0, at which point the function returns 1. The factorial of a number can also be computed using a loop. For example, the following program uses a for loop to compute the factorial of a number: ```
def factorial(n):
result = 1
for i in range(1, n+1):
result *= i
return result

감정 분석 프롬프트

Mixtral 8x7B에서 다음과 같은 프롬프트를 사용하여 감정 분석을 수행할 수 있습니다.

payload = { "inputs": """
Tweet: "I hate it 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:""", "parameters": { "max_new_tokens": 2,
},
}
predictor.predict(payload)

다음과 같은 결과가 나타납니다.

Input Text: Tweet: "I hate it 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:
Generated Text:  Positive

질문 답변 프롬프트

Mixtral-8x7B에서 다음과 같은 질문 응답 프롬프트를 사용할 수 있습니다.

# Question answering
payload = { "inputs": "Could you remind me when was the C programming language invented?", "parameters": { "max_new_tokens": 100, },
}
query_endpoint(payload)

다음과 같은 결과가 나타납니다.

Input Text: Could you remind me when was the C programming language invented?
Generated Text: C was invented in 1972 by Dennis Ritchie at Bell Labs. C is a general-purpose programming language. It was invented to write the UNIX operating system. C is a structured programming language. It is a middle-level language. It is a procedural language. C is a compiled language. It is a portable language. C is a case-sensitive language. It is a free-form language

Mixtral-8x7B 지시

Mixtral-8x7B의 지침 조정 버전은 대화 역할이 사용자 프롬프트로 시작하고 사용자 지침과 보조자(모델 답변)를 번갈아 가며 시작해야 하는 형식화된 지침을 허용합니다. 명령 형식을 엄격하게 준수해야 합니다. 그렇지 않으면 모델이 최적이 아닌 출력을 생성합니다. 교육 모델에 대한 프롬프트를 작성하는 데 사용되는 템플릿은 다음과 같이 정의됩니다.

<s> [INST] Instruction [/INST] Model answer</s> [INST] Follow-up instruction [/INST]]

참고 <s></s> 문자열의 시작(BOS)과 문자열의 끝(EOS)에 대한 특수 토큰입니다. [INST][/INST] 일반 문자열입니다.

다음 코드는 명령 형식으로 프롬프트의 형식을 지정하는 방법을 보여줍니다.

from typing import Dict, List def format_instructions(instructions: List[Dict[str, str]]) -> List[str]: """Format instructions where conversation roles must alternate user/assistant/user/assistant/...""" prompt: List[str] = [] for user, answer in zip(instructions[::2], instructions[1::2]): prompt.extend(["<s>", "[INST] ", (user["content"]).strip(), " [/INST] ", (answer["content"]).strip(), "</s>"]) prompt.extend(["<s>", "[INST] ", (instructions[-1]["content"]).strip(), " [/INST] ","</s>"]) return "".join(prompt) def print_instructions(prompt: str, response: str) -> None: bold, unbold = '33[1m', '33[0m' print(f"{bold}> Input{unbold}n{prompt}nn{bold}> Output{unbold}n{response[0]['generated_text']}n")

지식 검색

지식 검색 프롬프트에 다음 코드를 사용할 수 있습니다.

instructions = [{"role": "user", "content": "what is the recipe of mayonnaise?"}]
prompt = format_instructions(instructions)
payload = { "inputs": prompt, "parameters": {"max_new_tokens": 315, "do_sample": True}
}
response=predictor.predict(payload)
print_instructions(prompt, response)

다음과 같은 결과가 나타납니다.

> Input
<s>[INST] what is the recipe of mayonnaise? [/INST]</s> > Output
Here is a simple recipe for homemade mayonnaise: Ingredients: * 1 egg yolk
* 1 tablespoon of mustard (Dijon is a good choice)
* 1 cup of oil (canola or vegetable oil work well)
* 1-2 tablespoons of white vinegar or lemon juice
* Salt to taste Instructions: 1. In a medium bowl, whisk together the egg yolk and mustard. It is important that these ingredients are at room temperature.
2. Start adding the oil drop by drop, whisking continuously. This step is crucial to ensure that the mayonnaise emulsifies and does not separate.
3. Once you have added about a quarter of the oil and the mixture has thickened, you can start adding the oil in a thin stream, still whisking constantly.
4. When all the oil has been incorporated and the mayonnaise is thick, whisk in the vinegar or lemon juice and salt to taste.
5. If the mayonnaise is too thick, you can thin it with a little water.
6. Store the mayonnaise in the refrigerator and use within a few days. Note: It is important to use pasteurized eggs or egg yolks when making homemade mayonnaise to reduce the risk of foodborne illness.

코딩

Mixtral 모델은 다음 코드와 같이 코딩 작업에 대한 벤치마크 강점을 보여줄 수 있습니다.

instructions = [
{ "role": "user", "content": "In Bash, how do I list all text files in the current directory (excluding subdirectories) that have been modified in the last month?",
}
]
prompt = format_instructions(instructions)
payload = { "inputs": prompt, "parameters": {"max_new_tokens": 256, "do_sample": True, "temperature": 0.2}
}
response=predictor.predict(payload)
print_instructions(prompt, response)

다음과 같은 결과가 나타납니다.

> 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]</s>
> Output
ef{0.15cm} To list all text files in the current directory that have been modified in the last month, you can use a combination of the `find` and `grep` commands in Bash. Here's the command you're looking for: ```bash
find . -maxdepth 1 -type f -name "*.txt" -mtime -30
``` Let's break down this command: - `find .` starts a search in the current directory.
- `-maxdepth 1` limits the search to the current directory only (excluding subdirectories).
- `-type f` specifies that you're looking for files.
- `-name "*.txt"` filters the results to only include files with a `.txt` extension.
- `-mtime -30` filters the results to only include files modified within the last 30 days. This command will output the paths of all text files in the current directory that have been modified in the last month.

수학과 추론

Mixtral 모델은 또한 수학 정확도의 강점을 보고합니다.

instructions = [
{ "role": "user", "content": "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.",
}
]
prompt = format_instructions(instructions)
payload = { "inputs": prompt, "parameters": {"max_new_tokens": 600, "do_sample": True, "temperature": 0.2}
}
response=predictor.predict(payload)
print_instructions(prompt, response)

Mixtral 모델은 수학 논리를 사용하여 다음 출력에 표시된 대로 이해력을 제공할 수 있습니다.

> 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] </s>
> Output
First, let's calculate the total cost of the ice cream cones. Since each cone costs $1.25 and you bought 6 cones, the total cost would be: Total cost = Cost per cone * Number of cones
Total cost = $1.25 * 6
Total cost = $7.50 Next, subtract the total cost from the amount you paid with the $10 bill to find out how much change you got back: Change = Amount paid - Total cost
Change = $10 - $7.50
Change = $2.50 So, you got $2.50 back.

정리

노트북 실행을 마친 후 해당 프로세스에서 생성한 모든 리소스를 삭제하면 요금 청구가 중지됩니다. 다음 코드를 사용하세요.

predictor.delete_model()
predictor.delete_endpoint()

결론

이 게시물에서는 SageMaker Studio에서 Mixtral-8x7B를 시작하고 추론을 위해 모델을 배포하는 방법을 보여주었습니다. 기초 모델은 사전 훈련되어 있으므로 훈련 및 인프라 비용을 낮추고 사용 사례에 맞게 사용자 정의할 수 있습니다. 지금 SageMaker Studio에서 SageMaker JumpStart를 방문하여 시작하세요.

제품 자료


저자 소개

이제 Amazon SageMaker JumpStart에서 Mixtral-8x7B를 사용할 수 있습니다 | Amazon Web Services PlatoBlockchain 데이터 인텔리전스. 수직 검색. 일체 포함.라크나 차다 AWS Strategic Accounts의 수석 솔루션 아키텍트 AI/ML입니다. Rachna는 AI의 윤리적이고 책임 있는 사용이 미래의 사회를 개선하고 경제 및 사회적 번영을 가져올 수 있다고 믿는 낙관론자입니다. 여가 시간에 Rachna는 가족과 함께 시간을 보내고, 하이킹을 하고, 음악을 듣는 것을 좋아합니다.

이제 Amazon SageMaker JumpStart에서 Mixtral-8x7B를 사용할 수 있습니다 | Amazon Web Services PlatoBlockchain 데이터 인텔리전스. 수직 검색. 일체 포함.카일 울리히 박사 는 응용 과학자입니다. Amazon SageMaker 내장 알고리즘 팀. 그의 연구 관심사는 확장 가능한 기계 학습 알고리즘, 컴퓨터 비전, 시계열, 베이지안 비모수 및 가우시안 프로세스를 포함합니다. Duke University에서 박사 학위를 받았으며 NeurIPS, Cell 및 Neuron에 논문을 발표했습니다.

이제 Amazon SageMaker JumpStart에서 Mixtral-8x7B를 사용할 수 있습니다 | Amazon Web Services PlatoBlockchain 데이터 인텔리전스. 수직 검색. 일체 포함.크리스토퍼 휘튼 JumpStart 팀의 소프트웨어 개발자입니다. 그는 모델 선택을 확장하고 모델을 다른 SageMaker 서비스와 통합하는 데 도움을 줍니다. Chris는 다양한 비즈니스 영역에서 AI의 편재성을 가속화하는 데 열정을 쏟고 있습니다.

이제 Amazon SageMaker JumpStart에서 Mixtral-8x7B를 사용할 수 있습니다 | Amazon Web Services PlatoBlockchain 데이터 인텔리전스. 수직 검색. 일체 포함.파비오 노나토 데 파울라 박사 그는 모델 공급자와 고객이 AWS에서 생성 AI를 확장하도록 돕는 전문가 GenAI SA의 수석 관리자입니다. Fabio는 생성적 AI 기술에 대한 접근을 민주화하는 데 열정을 갖고 있습니다. 직장 밖에서는 파비오가 소노마 밸리 언덕에서 오토바이를 타거나 코믹솔로지(ComiXology)를 읽는 모습을 볼 수 있습니다.

이제 Amazon SageMaker JumpStart에서 Mixtral-8x7B를 사용할 수 있습니다 | Amazon Web Services PlatoBlockchain 데이터 인텔리전스. 수직 검색. 일체 포함.Ashish Khetan 박사 Amazon SageMaker 내장 알고리즘을 사용하는 수석 응용 과학자이며 기계 학습 알고리즘 개발을 돕습니다. 그는 University of Illinois Urbana-Champaign에서 박사 학위를 받았습니다. 그는 기계 학습 및 통계적 추론 분야에서 활동적인 연구원이며 NeurIPS, ICML, ICLR, JMLR, ACL 및 EMNLP 컨퍼런스에서 많은 논문을 발표했습니다.

이제 Amazon SageMaker JumpStart에서 Mixtral-8x7B를 사용할 수 있습니다 | Amazon Web Services PlatoBlockchain 데이터 인텔리전스. 수직 검색. 일체 포함.칼 알베르센 Amazon SageMaker 알고리즘 및 SageMaker의 기계 학습 허브인 JumpStart의 제품, 엔지니어링 및 과학을 이끌고 있습니다. 그는 기계 학습을 적용하여 비즈니스 가치를 창출하는 데 열정적입니다.

타임 스탬프 :

더보기 AWS 기계 학습