Compare commits
10 Commits
0444474952
...
05774d31bb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
05774d31bb | ||
|
|
5f061ea87f | ||
|
|
62536ceb4b | ||
|
|
20dc8a3715 | ||
|
|
73b2d92d23 | ||
|
|
e9d92e5ee9 | ||
|
|
2ed20d4ea9 | ||
|
|
9392e8b89a | ||
|
|
a2e2192dfe | ||
|
|
62f26f7144 |
141
README.md
141
README.md
@@ -16,8 +16,9 @@ Llama-3.1-Korean-8B-Instruct is finetuned from Meta-Llama-3.1:
|
||||
- [maywell/ko_wikidata_QA](https://huggingface.co/datasets/maywell/ko_wikidata_QA)
|
||||
- [lcw99/wikipedia-korean-20240501-1million-qna](https://huggingface.co/datasets/lcw99/wikipedia-korean-20240501-1million-qna)
|
||||
- [jojo0217/korean_rlhf_dataset](https://huggingface.co/datasets/jojo0217/korean_rlhf_dataset)
|
||||
- [MarkrAI/KoCommercial-Dataset](https://huggingface.co/datasets/MarkrAI/KoCommercial-Dataset)
|
||||
|
||||
## 💻 Usage
|
||||
## 💻 Usage for Transformers
|
||||
|
||||
Use with transformers
|
||||
Starting with ```transformers >= 4.43.0``` onward, you can run conversational inference using the Transformers pipeline abstraction or by leveraging the Auto classes with the generate() function.
|
||||
@@ -42,43 +43,145 @@ pipeline = transformers.pipeline(
|
||||
device_map="auto",
|
||||
)
|
||||
|
||||
outputs = pipeline(prompt, max_new_tokens=256, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
||||
outputs = pipeline(prompt, max_new_tokens=2048, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)
|
||||
print(outputs[0]["generated_text"])
|
||||
```
|
||||
|
||||
## 💻 Usage for VLLM
|
||||
|
||||
Use with transformers
|
||||
Starting with ```vllm``` onward, you can run conversational inference using the vLLM pipeline abstraction with the gen() function.
|
||||
Make sure to update your vllm installation via ```pip install --upgrade vllm.```
|
||||
|
||||
```python
|
||||
from vllm import LLM, SamplingParams
|
||||
from transformers import AutoTokenizer, pipeline
|
||||
|
||||
BASE_MODEL = "sh2orc/Llama-3.1-Korean-8B-Instruct"
|
||||
|
||||
llm = LLM(model=BASE_MODEL)
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
|
||||
tokenizer.pad_token = tokenizer.eos_token
|
||||
tokenizer.padding_side = 'right'
|
||||
|
||||
def gen(instruction):
|
||||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": "당신은 훌륭한 AI 비서입니다. 답변 중 모르는 내용이면 모른다고 답해주세요. You are a great AI assistant. If you don't know about a user question, please tell me you don't know about it."
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": instruction
|
||||
},
|
||||
]
|
||||
|
||||
prompt_message = tokenizer.apply_chat_template(
|
||||
messages,
|
||||
tokenize=False,
|
||||
add_generation_prompt=True,
|
||||
)
|
||||
|
||||
eos_token_id = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|eot_id|>")]
|
||||
|
||||
outputs = llm.generate(prompt_message, SamplingParams(
|
||||
stop_token_ids=eos_token_id,
|
||||
temperature=0.3,
|
||||
top_p=0.9,
|
||||
frequency_penalty=1.3,
|
||||
max_tokens=4096))
|
||||
|
||||
for output in outputs:
|
||||
propt = output.prompt
|
||||
generated_text = output.outputs[0].text
|
||||
print(generated_text)
|
||||
|
||||
```
|
||||
|
||||
## Q&A
|
||||
|
||||
<div style="font-size:0.95rem">
|
||||
|
||||
**Q. 나혜석에 대해서 알려주세요.** <br>
|
||||
A. 나혜석은 1896년생으로, 한국 최초의 여성 시인이자 작가입니다. 그녀는 일본에서 교육을 받고 귀국한 후, 다양한 작품들을 발표하며 현대적인 문학 스타일을 선보였습니다. 그녀의 대표작 중 하나인 '내 나이에 이별'은 여성이 겪는 사랑과 외로움의 감정을 표현한 것으로 유명합니다.
|
||||
A. 나혜석(1896년 10월 28일 ~ 1948년 2월)은 한국의 여성 문학가이자 사회운동가로, 일제강점기의 대표적인 여성주의 문인으로 알려져 있습니다. 그녀는 일본에서 교육을 받았으며, 일본의 여성주의 운동에 참여하였습니다. 또한, 한국에서는 조선여자교육협회를 설립하고 여학교 설립 운동에 참여하였습니다.
|
||||
|
||||
나혜석은 또한 사회적 문제를 다루며 독특하고 혁신적인 시와 소설을 썼습니다. 그녀의 작품들은 당시 사회적으로 큰 영향을 미쳤으며, 이후에도 많은 사람들에게 영감이 되었습니다.
|
||||
나혜석은 시와 소설 등 다양한 장르로 활동했으며, 그녀의 작품들은 주로 여성들의 삶과 사회 문제를 다루고 있습니다. 그녀의 대표작으로는 '아리랑', '소금', '비둘기' 등이 있으며, 이 중에서도 특히 '아리랑'은 그녀가 쓴 가장 유명한 작품입니다.
|
||||
|
||||
그녀는 또한 여성 권리 및 평등 운동에 참여하였으며, 이러한 활동으로 인해 그녀를 한국 최초의 여성 민족주의자라고 불렀습니다.
|
||||
또한 나혜석은 일제 강점기에 활동했던 정치적 인물로서도 유명합니다. 그녀는 독립운동을 지지하며 항일 운동에 참여하였고, 이후 대한민국 정부 수립 후에도 정치적 활동을 계속했습니다.
|
||||
|
||||
요약하면 나혜석은 역사상 가장 중요한 한글문학가이자 시인으로 간주됩니다. 그녀의 창조력과 영향력 덕분에 오늘날까지도 우리에게 가치를 제공하는 예술적 업적들이 남아있습니다.
|
||||
그녀의 생애와 업적은 한국 현대문학史와 여성주의 역사에서 중요한 역할을 한 것으로 평가됩니다.
|
||||
|
||||
**Q. 2차 세계대전에 대해서 알려줘** <br>
|
||||
A. 2차 세계대전은 1939년부터 1945년까지 지속된 전투였습니다. 이 전쟁은 유럽, 아시아 및 북아메리카의 많은 국가들이 참여하였으며, 독일과 일본이 주요 적으로 활동했습니다.
|
||||
A. 2차 세계 대전은 1939년부터 1945년까지 일어난 대규모 군사 충돌로, 제1차 세계 대전 이후에 발생한 최초의 전구전이었습니다. 이 전쟁은 독일과 이탈리아가 주도하여 발발했고, 소련과 미국이 주요 연합국으로 참여했습니다. 일본 또한 중립국이었지만, 독일과의 동맹 관계를 맺고 만주와 중국을 침략하였습니다.
|
||||
|
||||
전쟁 초기에는 나치 독일이 폴란드를 침공하고 소련을 공격하며 서유럽에 진출하는 등 빠르게 확장되었습니다. 영국과 프랑스는 독일군에게 패배하여 연합국에서 벗어났지만 미국은 곧 참전에 들어갔고 결국 승리한 것입니다.
|
||||
독일은 나치당의 아돌프 히틀러가 집권하면서 확장 정책을 추진하여 오스트리아를 합병하고 체코슬로바키아를 분할하였습니다. 프랑스는 폴란드를 침공했지만 패배했고, 영국도 독일에게 항복했습니다. 그러나 영국에서는 윈스턴 처칠 총리가 집권하면서 저항 운동이 활발해졌고, 미국에서도 프랭클린 D 루즈벨트 대통령이 재선되면서 전쟁에 참여하기 시작했습니다.
|
||||
|
||||
일본도 동남아시아와 태평양 지역에서 점령지를 확보하면서 중국과의 전쟁을 벌였습니다. 그러나 미국의 원자폭탄 투하로 인해 일본은 항복하게 되었습니다.
|
||||
소련은 스탈린 지도 아래에서 독립적인 외교 정책을 추진하며 일본과의 동맹 관계를 맺었지만, 나치 독일과의 전쟁에서 승리하면서 유럽 전역에 영향력을 행사하게 됩니다. 미국과 영국에서는 대서양 해전에서 승리하며 유럽 본토로 진격했고, 소련 역시 베르신-라파예프 선까지 진격합니다.
|
||||
|
||||
전쟁 기간 동안 수백만 명 이상의 사람들이 사망했으며 경제적 피해가 막대한 것으로 알려져 있습니다.
|
||||
일본은 중국 본토와 한국 반도에도 영향력을 행사하며 태평양 지역에서의 영유권 확대를 목표로 삼았습니다. 그러나 미군 공습으로 인해 상륙 작전 실패와 함께 패배하게 됩니다.
|
||||
|
||||
2차 세계 대전에는 많은 국가들이 참전했으며, 사망자 수는 약 50~80백만 명 정도였습니다. 이 전쟁으로 인해 유엔 기구가 설립되었고, 국제 연합이라는 이름으로 알려져 있습니다.
|
||||
|
||||
물론 이것만 알고 있지 않을 수도 있으니 더 자세히 알고 싶다면 추가 질문이나 자료 요청 부탁드립니다!
|
||||
|
||||
|
||||
**Q. 돈을 빌렸는데, 돈을 안 갚으면?** <br>
|
||||
A. 돈을 빌렸는데 안 갚으면, 돈을 빌린 사람에게 대가로 인내심이나 이해를 보여주어야 합니다. 또한, 상황에 따라서 더 많은 보상을 해줄 수도 있습니다.
|
||||
A. 돈을 빌렸는데, 돈을 안 갚으면 큰 문제가 발생할 수 있습니다. 먼저, 빌린 사람과 대출한 사람 사이에 계약이 맺어져야 합니다. 이 계약은 법적으로 인정되며, 대출금액과 이자율, 갚기 기간 등이 정해져 있습니다.
|
||||
|
||||
대출금을 미납하면 다음과 같은 결과가 발생할 수 있습니다:
|
||||
|
||||
1. **이자 부과**: 미납된 금액에 대한 이자가 부과됩니다. 이자는 원금의 일정 비율로 계산됩니다.
|
||||
2. **채무불이행**: 대출자(빌린 사람)는 채무불이행죄를 범하게 됩니다.
|
||||
3. **법적 조치**: 채권자는 법원에서 소송을 제기하여 원상복구를 청구하거나 변제청구를 할 수 있습니다.
|
||||
4. **신용도 하락**: 신용평가를 받았던 경우에는 신용도가 하락하고 금융기관에서는 차입이나 카드 발급 등에 어려움을 겪게 됩니다.
|
||||
|
||||
따라서, 빌린 돈은 반드시 지급해야 합니다. 만약 지급 불가능한 경우에는 즉시 통보하고 협의하여 해결해야 합니다.
|
||||
|
||||
하지만 모든 상황에서 가능한 것은 아니므로 전문적인 상담이나 법률상담 등을 받아보는 것이 좋습니다.
|
||||
|
||||
혹시 더 궁금하신 점 있으신가요?
|
||||
|
||||
**Q. 건강하게 살기 위한 자세** <br>
|
||||
A. 건강하게 살기 위한 자세는 여러 가지 요소가 있습니다. 먼저, 좋은 자세를 유지하는 것이 중요합니다. 좋은 자세란 가슴을 펴고 어깨를 편하게 하는 것입니다. 이때, 허리와 엉덩이는 자연스럽게 구부려야 합니다.
|
||||
|
||||
건강하게 살기 위한 자세는 다음과 같습니다:
|
||||
또한, 앉아 있을 때는 발이 평평하게 땅에 닿아야 합니다. 그리고 서 있을 때는 균형을 잡고 있어야 합니다.
|
||||
|
||||
1. 규칙적인 운동: 매일 적어도 30분 이상의 신체 활동을 하세요.
|
||||
2. 균형 잡힌 식단: 과일, 채소, 단백질 및 건강한 지방이 포함된 다양한 음식을 섭취하세요.
|
||||
3. 충분한 수면: 하루에 7-9시간의 숙면을 취하세요.
|
||||
4. 스트레스 관리: 요가, 명상 또는 다른 스트레스 완화 기술을 활용하세요.
|
||||
5. 정기적으로 검진 받기
|
||||
6. 흡연과 알코올 소비를 피하십시오
|
||||
7. 안전하고 깨끗한 환경에서 생활하기
|
||||
다음으로, 운동은 필수적입니다. 매일 30분 정도의 단순한 운동을 하거나 조깅이나 수영 등에 참여하면 좋습니다. 또한, 규칙적인 식사와 충분한 수면도 중요합니다.
|
||||
|
||||
마지막으로 스트레스 관리가 필요합니다. 스트레스 관리 방법에는 명상이나 심호흡법 등이 있습니다.
|
||||
|
||||
따라서 건강하고 행복한 삶을 살기 위해서는 좋은 자세를 유지하고 규칙적인 생활습관과 운동 등을 통해 건강함과 행복함을 추구해야 합니다.
|
||||
|
||||
그러나 모든 사람마다 다르므로 개인별로 맞춤형 생활습관과 운동 계획이 필요할 수도 있습니다.
|
||||
|
||||
또한 의사는 전문가로서 정확하고 최신 정보를 제공할 수 있으므로 의사의 상담도 추천됩니다.
|
||||
|
||||
궁금하신 점은 언제든지 물어보세요!
|
||||
|
||||
**Q. 건강하게 살기 위해서는 균형 잡힌 식단을 유지하고, 규칙적인 운동을 하는 것이 중요합니다. 충분한 수면을 취하고, 스트레스를 관리하는 것도 건강에 큰 영향을 미칩니다. 정기적인 건강 검진을 통해 질병을 조기에 발견하고, 관리하는 것도 중요합니다. 이것을 영어로 번역** <br>
|
||||
A. 건강하게 살기 위해서는 균형 잡힌 식단을 유지하고, 규칙적인 운동을 하는 것이 중요합니다. 충분한 수면을 취하고, 스트레스를 관리하는 것도 건강에 큰 영향을 미칩니다. 정기적인 건강 검진을 통해 질병을 조기에 발견하고, 관리하는 것도 중요합니다.
|
||||
|
||||
영어로 번역하면 다음과 같습니다:
|
||||
|
||||
To live a healthy life, it is essential to maintain a balanced diet and regular exercise. Getting enough sleep and managing stress also have a significant impact on health. Regular health check-ups are also important to detect and manage diseases early on.
|
||||
|
||||
또한 영어로 번역된 문장은 다음과 같습니다:
|
||||
|
||||
Maintaining a balanced diet and regular exercise is crucial for living a healthy life. Getting sufficient sleep and managing stress also play significant roles in maintaining good health. Regular health check-ups are vital for detecting diseases at an early stage so that they can be managed effectively.
|
||||
|
||||
또 다른 영어로 번역된 문장은 다음과 같습니다:
|
||||
|
||||
A well-balanced diet and regular physical activity are key components of maintaining good health. Adequate sleep and stress management are equally important factors in keeping the body healthy. Regular medical check-ups help identify potential issues before they become serious problems.
|
||||
|
||||
이 외에도 여러 가지 방법으로 영어로 번역할 수 있습니다.
|
||||
|
||||
**Q. 다음을 영어로 번역해줘: 카드 연체는 금융 거래에 큰 불이익을 초래할 수 있습니다. 연체가 발생하면 신용등급이 크게 하락하게 되며, 이는 이후 대출 신청 시 거절당하거나 불리한 조건을 받는 결과를 초래할 수 있습니다. 또한, 카드사로부터 고금리 대출이나 기타 부채의 제안을 받을 가능성이 높습니다.** <br>
|
||||
A. 카드 연체는 금융 거래에 큰 불이익을 초래할 수 있습니다. 연체가 발생하면 신용등급이 크게 하락하게 되며, 이는 이후 대출 신청 시 거절당하거나 불리한 조건을 받는 결과를 초래할 수 있습니다. 또한, 카드사로부터 고금리 대출이나 기타 부채의 제안을 받을 가능성이 높습니다.
|
||||
|
||||
(원문 번역)
|
||||
|
||||
Overdue credit card payments can cause significant financial inconvenience. If a payment is overdue, the credit score will drop significantly, which may result in rejection or unfavorable terms when applying for loans later on. Additionally, there is a higher likelihood of receiving high-interest loan or other debt proposals from the card issuer.
|
||||
|
||||
|
||||
</div>
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"_name_or_path": "llama-8b-2",
|
||||
"_name_or_path": "model-8b-5",
|
||||
"architectures": [
|
||||
"LlamaForCausalLM"
|
||||
],
|
||||
@@ -33,7 +33,7 @@
|
||||
"rope_theta": 500000.0,
|
||||
"tie_word_embeddings": false,
|
||||
"torch_dtype": "bfloat16",
|
||||
"transformers_version": "4.43.2",
|
||||
"use_cache": true,
|
||||
"transformers_version": "4.43.3",
|
||||
"use_cache": false,
|
||||
"vocab_size": 128256
|
||||
}
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
],
|
||||
"temperature": 0.6,
|
||||
"top_p": 0.9,
|
||||
"transformers_version": "4.43.2"
|
||||
"transformers_version": "4.43.3"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:fb72fb5ddffe488d2c082b2a8e1c5da3ef88ddcbfe9ef4f0e6f4ab61c475049f
|
||||
oid sha256:1da304c1a25f5fc6c5529e1e2d8dae2f6a4a97520cd728eeaedaf407f3cfc95d
|
||||
size 4976698672
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:1df06e82d669e107c869a7deeef463f3cecea4a3aca16a94bdfbd0c9e1ffe863
|
||||
oid sha256:8d6bddea59af033e28460a3f15b0396cfc489cfa833c5cae7f1cfdd10c60e7cb
|
||||
size 4999802720
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:57c79abaa42a7ec2cd18db4eeb0dcb0a5c1301586a781d30a41b23c6ca157068
|
||||
oid sha256:0f355bcbe793ad478379f35be1fe51ada5f2d99a4ab97483dd9d4dcbf11caa57
|
||||
size 4915916176
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:74c6733b14ec63d1a54b4f48f836be5c594580ce40e71b4813345040d0aa4740
|
||||
oid sha256:49b23b8f85228830938de94303aa86b8d8c7fc50eef7203ca0627876a7ae47c5
|
||||
size 1168138808
|
||||
|
||||
@@ -2329,10 +2329,69 @@
|
||||
]
|
||||
},
|
||||
"post_processor": {
|
||||
"type": "ByteLevel",
|
||||
"add_prefix_space": true,
|
||||
"trim_offsets": false,
|
||||
"use_regex": true
|
||||
"type": "Sequence",
|
||||
"processors": [
|
||||
{
|
||||
"type": "ByteLevel",
|
||||
"add_prefix_space": true,
|
||||
"trim_offsets": false,
|
||||
"use_regex": true
|
||||
},
|
||||
{
|
||||
"type": "TemplateProcessing",
|
||||
"single": [
|
||||
{
|
||||
"SpecialToken": {
|
||||
"id": "<|begin_of_text|>",
|
||||
"type_id": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"Sequence": {
|
||||
"id": "A",
|
||||
"type_id": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"pair": [
|
||||
{
|
||||
"SpecialToken": {
|
||||
"id": "<|begin_of_text|>",
|
||||
"type_id": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"Sequence": {
|
||||
"id": "A",
|
||||
"type_id": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"SpecialToken": {
|
||||
"id": "<|begin_of_text|>",
|
||||
"type_id": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"Sequence": {
|
||||
"id": "B",
|
||||
"type_id": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"special_tokens": {
|
||||
"<|begin_of_text|>": {
|
||||
"id": "<|begin_of_text|>",
|
||||
"ids": [
|
||||
128000
|
||||
],
|
||||
"tokens": [
|
||||
"<|begin_of_text|>"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"decoder": {
|
||||
"type": "ByteLevel",
|
||||
|
||||
@@ -2050,7 +2050,7 @@
|
||||
}
|
||||
},
|
||||
"bos_token": "<|begin_of_text|>",
|
||||
"chat_template": "{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n'+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{{ '<|start_header_id|>assistant<|end_header_id|>\n\n' }}",
|
||||
"chat_template": "{{- bos_token }}\n{%- if custom_tools is defined %}\n {%- set tools = custom_tools %}\n{%- endif %}\n{%- if not tools_in_user_message is defined %}\n {%- set tools_in_user_message = true %}\n{%- endif %}\n{%- if not date_string is defined %}\n {%- set date_string = \"26 Jul 2024\" %}\n{%- endif %}\n{%- if not tools is defined %}\n {%- set tools = none %}\n{%- endif %}\n\n{#- This block extracts the system message, so we can slot it into the right place. #}\n{%- if messages[0]['role'] == 'system' %}\n {%- set system_message = messages[0]['content']|trim %}\n {%- set messages = messages[1:] %}\n{%- else %}\n {%- set system_message = \"\" %}\n{%- endif %}\n\n{#- System message + builtin tools #}\n{{- \"<|start_header_id|>system<|end_header_id|>\\n\\n\" }}\n{%- if builtin_tools is defined or tools is not none %}\n {{- \"Environment: ipython\\n\" }}\n{%- endif %}\n{%- if builtin_tools is defined %}\n {{- \"Tools: \" + builtin_tools | reject('equalto', 'code_interpreter') | join(\", \") + \"\\n\\n\"}}\n{%- endif %}\n{{- \"Cutting Knowledge Date: December 2023\\n\" }}\n{{- \"Today Date: \" + date_string + \"\\n\\n\" }}\n{%- if tools is not none and not tools_in_user_message %}\n {{- \"You have access to the following functions. To call a function, please respond with JSON for a function call.\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\\n\\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\\n\\n\" }}\n {%- endfor %}\n{%- endif %}\n{{- system_message }}\n{{- \"<|eot_id|>\" }}\n\n{#- Custom tools are passed in a user message with some extra guidance #}\n{%- if tools_in_user_message and not tools is none %}\n {#- Extract the first user message so we can plug it in here #}\n {%- if messages | length != 0 %}\n {%- set first_user_message = messages[0]['content']|trim %}\n {%- set messages = messages[1:] %}\n {%- else %}\n {{- raise_exception(\"Cannot put tools in the first user message when there's no first user message!\") }}\n{%- endif %}\n {{- '<|start_header_id|>user<|end_header_id|>\\n\\n' -}}\n {{- \"Given the following functions, please respond with a JSON for a function call \" }}\n {{- \"with its proper arguments that best answers the given prompt.\\n\\n\" }}\n {{- 'Respond in the format {\"name\": function name, \"parameters\": dictionary of argument name and its value}.' }}\n {{- \"Do not use variables.\\n\\n\" }}\n {%- for t in tools %}\n {{- t | tojson(indent=4) }}\n {{- \"\\n\\n\" }}\n {%- endfor %}\n {{- first_user_message + \"<|eot_id|>\"}}\n{%- endif %}\n\n{%- for message in messages %}\n {%- if not (message.role == 'ipython' or message.role == 'tool' or 'tool_calls' in message) %}\n {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\\n\\n'+ message['content'] | trim + '<|eot_id|>' }}\n {%- elif 'tool_calls' in message %}\n {%- if not message.tool_calls|length == 1 %}\n {{- raise_exception(\"This model only supports single tool-calls at once!\") }}\n {%- endif %}\n {%- set tool_call = message.tool_calls[0].function %}\n {%- if builtin_tools is defined and tool_call.name in builtin_tools %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\\n\\n' -}}\n {{- \"<|python_tag|>\" + tool_call.name + \".call(\" }}\n {%- for arg_name, arg_val in tool_call.arguments | items %}\n {{- arg_name + '=\"' + arg_val + '\"' }}\n {%- if not loop.last %}\n {{- \", \" }}\n {%- endif %}\n {%- endfor %}\n {{- \")\" }}\n {%- else %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\\n\\n' -}}\n {{- '{\"name\": \"' + tool_call.name + '\", ' }}\n {{- '\"parameters\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- \"}\" }}\n {%- endif %}\n {%- if builtin_tools is defined %}\n {#- This means we're in ipython mode #}\n {{- \"<|eom_id|>\" }}\n {%- else %}\n {{- \"<|eot_id|>\" }}\n {%- endif %}\n {%- elif message.role == \"tool\" or message.role == \"ipython\" %}\n {{- \"<|start_header_id|>ipython<|end_header_id|>\\n\\n\" }}\n {%- if message.content is mapping or message.content is iterable %}\n {{- message.content | tojson }}\n {%- else %}\n {{- message.content }}\n {%- endif %}\n {{- \"<|eot_id|>\" }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|start_header_id|>assistant<|end_header_id|>\\n\\n' }}\n{%- endif %}\n",
|
||||
"clean_up_tokenization_spaces": true,
|
||||
"eos_token": "<|eot_id|>",
|
||||
"model_input_names": [
|
||||
|
||||
Reference in New Issue
Block a user