Text Generation
Transformers
PyTorch
Chinese
English
llama
text-generation-inference
File size: 13,841 Bytes
ef5a5e4
 
 
 
 
 
 
 
 
 
 
 
8a52c45
 
 
 
 
 
00a5d91
 
5e92279
 
 
 
 
 
 
e1c582c
 
8a52c45
 
 
 
e1c582c
 
 
 
 
9cbd412
e1c582c
 
 
 
 
 
 
 
 
 
 
 
 
8a52c45
 
 
 
 
 
 
 
 
 
 
0e79ea8
 
8a52c45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0e79ea8
 
8a52c45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00a5d91
8a52c45
 
 
 
 
 
 
 
 
 
 
 
 
a396a39
8a52c45
 
7715e0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ef5a5e4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
---
language:
- zh
- en
pipeline_tag: text-generation
inference: false
datasets:
- anon8231489123/ShareGPT_Vicuna_unfiltered
- QingyiSi/Alpaca-CoT
- mhhmm/leetcode-solutions-python
---

# baichuan-vicuna-7b
baichuan-vicuna-7b is a chat model supervised finetuned on vicuna sharegpt data.
- The foundation model is [baichuan-7B](https://huggingface.co/baichuan-inc/baichuan-7B), which is a large-scale pre-training model developed by Baichuan Intelligence allowing for commercial purposes.
- The finetuning data includes [ShareGPT](https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/blob/main/ShareGPT_V3_unfiltered_cleaned_split.json), mixed with [COT](https://huggingface.co/datasets/QingyiSi/Alpaca-CoT) and [Leetcode](https://www.kaggle.com/datasets/erichartford/leetcode-solutions), which are aimed to improve the model's reasoning and coding ability (the data mixing strategy is inspired by [TULU](https://arxiv.org/abs/2306.04751)).
- The training code is based on [FastChat](https://github.com/lm-sys/FastChat), with the prompt format consisting of [Vicuna v1.1](https://huggingface.co/lmsys/vicuna-7b-delta-v1.1).

[中文说明](#chinese-model-card)

# Load model
```python
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("fireballoon/baichuan-vicuna-7b", use_fast=False)
model = AutoModelForCausalLM.from_pretrained("fireballoon/baichuan-vicuna-7b")
```

# Inference
Inference with FastChat:
```
python3 -m fastchat.serve.cli --model-path fireballoon/baichuan-vicuna-7b
```

Inference with Transformers:
```ipython
>>> from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer
>>> tokenizer = AutoTokenizer.from_pretrained("fireballoon/baichuan-vicuna-7b", use_fast=False)
>>> model = AutoModelForCausalLM.from_pretrained("fireballoon/baichuan-vicuna-7b").half().cuda()
>>> streamer = TextStreamer(tokenizer, skip_prompt=True, skip_special_tokens=True)
>>> instruction = "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: {} ASSISTANT:"
>>> prompt = instruction.format("five tips to help with sleep")  # user message
>>> generate_ids = model.generate(tokenizer(prompt, return_tensors='pt').input_ids.cuda(), max_new_tokens=2048, streamer=streamer)
'''
1. Create a relaxing bedtime routine, such as winding down with a warm bath or reading a book before bed.
2. Avoid caffeine and alcohol close to bedtime, as they can disrupt sleep.
3. Use blackout curtains or shades to block out light from the outside, which can interfere with your body's natural sleep rhythms.
4. Keep your bedroom cool and dark, and avoid using electronic devices at least an hour before bed.
5. Regular exercise and a healthy diet can also help improve sleep quality.
'''
```


# Test examples on FastChat Eval
Test example on [FastChat Eval](https://github.com/lm-sys/FastChat/blob/main/fastchat/eval/table/question.jsonl)
```
Q: How can I improve my time management skills?

A: There are many different ways to improve your time management skills. Here are a few strategies that you may find helpful:                                                                                    
1 Prioritize your tasks: Make a list of all the tasks you need to complete and prioritize them based on importance and urgency. This will help you focus on the most important tasks and avoid getting bogged down by less critical items.                                                                                   
2 Use a time management planner: A planner can help you organize your time by breaking down your tasks into smaller, more manageable chunks. This can help you stay focused and on track.                             
3 Set clear boundaries: Setting clear boundaries between work time and personal time can help you avoid distractions and stay focused on your tasks. This may involve designating certain times of day or days of the week for work and other times for rest and leisure.                                                   
4 Take care of your physical and mental health: Taking care of your physical and mental health can help you be more productive and focused. This may involve getting enough sleep, eating a healthy diet, and taking breaks to relax and recharge.                                                                             
Remember that improving your time management skills takes practice and patience. Don't be discouraged if you make mistakes or experience setbacks. Keep trying and you will eventually develop better time management habits that will help you be more productive and successful.
```
```
Q: Can you help me write a formal email to a potential business partner proposing a joint venture?

A: Sure! Here is a sample formal email that you could use as a template to propose a joint venture with a       
potential business partner:                                                                                  

Subject: Proposal for Joint Venture                                                                          

Dear [Business Partner],                                                                                     

I hope this email finds you well. I am writing to propose a joint venture between our companies. We believe that a collaboration between our companies could bring significant benefits to both of us, and we would like to explore the possibility of forming a partnership.                                                         

Our companies have complementary strengths, and we believe that a joint venture could allow us to leverage those strengths to create new products, services, and opportunities. We believe that a joint venture could also provide increased revenue and growth for both of our companies.                                         

In order to explore the possibility of a joint venture, we would like to schedule a call to discuss the details of our proposal. During the call, we would like to discuss the terms of the joint venture, including the specific roles and responsibilities of each partner, the financial terms of the agreement, and any other relevant details.                                                                                            

I would be happy to schedule a call with you at your convenience. In the meantime, please feel free to contact me with any questions or concerns you may have about our proposal.                                   

Sincerely,                                                                                                   

[Your Name]
```
```
Q: Implement a binary search algorithm to find a specific element in a sorted array.

A: Here is an implementation of the binary search algorithm to find a specific element in a sorted array:                                                                                                             
 public static int binarySearch(int[] arr, int target) {                                                     
     int left = 0;                                                                                           
     int right = arr.length - 1;                                                                             
     while (left <= right) {                                                                                 
         int mid = left + (right - left) / 2;                                                                
         if (arr[mid] < target) {                                                                            
             left = mid + 1;                                                                                 
         } else if (arr[mid] > target) {                                                                     
             right = mid - 1;                                                                                
         } else {                                                                                            
             return mid;                                                                                     
         }                                                                                                   
     }                                                                                                       
     return -1; // target not found                                                                          
 }                                                                                                           
                                                                                                             
Here is how the binary search algorithm works:                                                               
 1 Initialize two pointers, left and right, to the beginning and end of the array, respectively.             
 2 While the left pointer is less than or equal to the right pointer, perform the following steps:           
    1 Calculate the middle index, mid, by dividing the left pointer and the right pointer.                   
    2 Check if the middle element, arr[mid], is less than or equal to the target value.                      
    3 If the middle element is less than the target value, update the left pointer to mid + 1.               
    4 If the middle element is greater than the target value, update the right pointer to mid - 1.           
    5 If the middle element is equal to the target value, the target element has been found, so return the middle index.                                                                                          
 3 If the target element is not found, return -1.                                                            

This algorithm has a runtime complexity of O(log n) and a space complexity of O(1), making it an efficient way to find a specific element in a sorted array. 
```

---

# Chinese model card

baichuan-vicuna-7b是在vicuna sharegpt数据上全参数微调的对话模型。
- 基座模型是[baichuan-7B](https://huggingface.co/baichuan-inc/baichuan-7B),由百川智能开发的可商用大规模预训练模型。
- 微调数据包括[ShareGPT](https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/blob/main/ShareGPT_V3_unfiltered_cleaned_split.json),混合一定比例的[COT](https://huggingface.co/datasets/QingyiSi/Alpaca-CoT)和[Leetcode](https://www.kaggle.com/datasets/erichartford/leetcode-solutions)数据以提升模型的推理和代码能力(数据混合策略受到[TULU](https://arxiv.org/abs/2306.04751)研究成果的启发)。
- 训练代码基于[FastChat](https://github.com/lm-sys/FastChat),使用[Vicuna](https://huggingface.co/lmsys/vicuna-7b-delta-v1.1)的prompt格式。


# Test examples on Ziyan Eval

在[Ziya-Eval-Chinese](https://huggingface.co/datasets/IDEA-CCNL/Ziya-Eval-Chinese)上的测试例子
```
Q: 鸿门宴是什么意思
A: 鸿门宴是一个汉语成语,意思是指在公元前206年,项羽、刘邦两军在鸿门(今陕西临潼区东北)一带展开的一场“生死对决”。当时,项羽的叔父项伯在会见刘邦的手下时,将刘邦已经逃走的情报透露给项羽,使得刘邦免于被项羽所杀。项羽因此怀恨在心,准备第二天在鸿门设宴,邀请刘邦赴宴,然后袭击刘邦,然而,项羽手下的谋士范增早已看出刘邦的“龙气象” 为刘邦是“沛公刘邦是高祖(刘邦的谥号),他将统率四海,认为杀掉沛公是上策”。宴会期间,项羽的堂弟项庄在席间舞剑,企图将刘邦刺杀。最后,刘邦借故离开,前往韩信大军的营地。鸿门宴上,刘邦因项伯的缘故逃过一劫,但是,他也失项羽议和的机会,为以后楚汉之争埋下了隐患。

Q: 中国目前通用的火警电话是
A: 目前,中国通用的是119火警电话。
```
```
Q: 晚上睡不着应该怎么办

A:失眠是一种症状,而不是一种疾病。治疗失眠的目标是解决其潜在原因。失眠的一些常见原因包括:                     

*睡眠不足                                                                                                    
*压力                                                                                                        
*心理健康问题 (焦虑,抑郁等)                                                                                 
*药物 (处方和非处方)                                                                                         
*环境因素 (噪音,光线,温度等)                                                                               

以下是一些通常可以帮助您睡眠的方法:                                                                         

*睡觉前4-6个小时避免刺激物 (咖啡因,尼古丁,酒精)                                                            
*睡前冥想以减少压力和焦虑                                                                                    
*睡觉前不要看亮屏幕 (电脑,手机,平板电脑等)                                                                 
*睡觉前至少一个小时不要运动                                                                                  
*睡觉前不要吃食物                                                                                            
*在睡觉前放松并平静下来 (看看书,喝杯牛奶等)                                                                 

如果这些技术不起作用,或者如果失眠是由药物或其他医学状况引起的,您应该联系您的医生。                         

```