bofenghuang
commited on
Commit
•
336a168
1
Parent(s):
d6e5944
Update doc
Browse files- README.md +57 -26
- logo_v2.jpg +0 -0
README.md
CHANGED
@@ -11,49 +11,80 @@ tags:
|
|
11 |
---
|
12 |
|
13 |
<p align="center" width="100%">
|
14 |
-
<img src="https://huggingface.co/bofenghuang/vigogne-2-7b-chat/resolve/
|
15 |
</p>
|
16 |
|
17 |
-
# Vigogne-2-7B-Chat: A Llama-2 based French chat
|
18 |
|
19 |
-
Vigogne-2-7B-Chat is a
|
20 |
|
21 |
-
|
22 |
|
23 |
-
**Usage and License Notices**: Vigogne-2-7B-Chat follows
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
## Usage
|
26 |
|
27 |
```python
|
28 |
import torch
|
29 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig
|
30 |
from vigogne.preprocess import generate_inference_chat_prompt
|
31 |
|
32 |
model_name_or_path = "bofenghuang/vigogne-2-7b-chat"
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
user_query = "Expliquez la différence entre DoS et phishing."
|
37 |
-
|
38 |
-
input_ids = tokenizer(prompt, return_tensors="pt")["input_ids"].to(model.device)
|
39 |
-
input_length = input_ids.shape[1]
|
40 |
-
|
41 |
-
generated_outputs = model.generate(
|
42 |
-
input_ids=input_ids,
|
43 |
-
generation_config=GenerationConfig(
|
44 |
-
temperature=0.1,
|
45 |
-
do_sample=True,
|
46 |
-
repetition_penalty=1.0,
|
47 |
-
max_new_tokens=512,
|
48 |
-
),
|
49 |
-
return_dict_in_generate=True,
|
50 |
-
)
|
51 |
-
generated_tokens = generated_outputs.sequences[0, input_length:]
|
52 |
-
generated_text = tokenizer.decode(generated_tokens, skip_special_tokens=True)
|
53 |
-
print(generated_text)
|
54 |
```
|
55 |
|
56 |
-
You can
|
57 |
|
58 |
<a href="https://colab.research.google.com/github/bofenghuang/vigogne/blob/main/notebooks/infer_chat.ipynb" target="_blank"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
|
59 |
|
|
|
11 |
---
|
12 |
|
13 |
<p align="center" width="100%">
|
14 |
+
<img src="https://huggingface.co/bofenghuang/vigogne-2-7b-chat/resolve/v2.0/logo_v2.jpg" alt="Vigogne" style="width: 30%; min-width: 300px; display: block; margin: auto;">
|
15 |
</p>
|
16 |
|
17 |
+
# Vigogne-2-7B-Chat-V2.0: A Llama-2 based French chat LLM
|
18 |
|
19 |
+
Vigogne-2-7B-Chat-V2.0 is a French chat LLM, based on [LLaMA-2-7B](https://ai.meta.com/llama), optimized to generate helpful and coherent responses in user conversations.
|
20 |
|
21 |
+
Check out our [blog](https://github.com/bofenghuang/vigogne/blob/main/blogs/2023-08-17-vigogne-chat-v2_0.md) and [GitHub repository](https://github.com/bofenghuang/vigogne) for more information.
|
22 |
|
23 |
+
**Usage and License Notices**: Vigogne-2-7B-Chat-V2.0 follows Llama-2's [usage policy](https://ai.meta.com/llama/use-policy). A significant portion of the training data is distilled from GPT-3.5-Turbo and GPT-4, kindly use it cautiously to avoid any violations of OpenAI's [terms of use](https://openai.com/policies/terms-of-use).
|
24 |
+
|
25 |
+
## Changelog
|
26 |
+
|
27 |
+
All previous versions are accessible through branches.
|
28 |
+
|
29 |
+
- **V1.0**: Trained on 420K chat data.
|
30 |
+
- **V2.0**: Trained on 520K data. Check out our [blog](https://github.com/bofenghuang/vigogne/blob/main/blogs/2023-08-17-vigogne-chat-v2_0.md) for more details.
|
31 |
|
32 |
## Usage
|
33 |
|
34 |
```python
|
35 |
import torch
|
36 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig, TextStreamer
|
37 |
from vigogne.preprocess import generate_inference_chat_prompt
|
38 |
|
39 |
model_name_or_path = "bofenghuang/vigogne-2-7b-chat"
|
40 |
+
revision = "v2.0"
|
41 |
+
|
42 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, revision=revision, padding_side="right", use_fast=False)
|
43 |
+
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, revision=revision, torch_dtype=torch.float16, device_map="auto")
|
44 |
+
|
45 |
+
streamer = TextStreamer(tokenizer, timeout=10.0, skip_prompt=True, skip_special_tokens=True)
|
46 |
+
|
47 |
+
|
48 |
+
def infer(
|
49 |
+
utterances,
|
50 |
+
system_message=None,
|
51 |
+
temperature=0.1,
|
52 |
+
top_p=1.0,
|
53 |
+
top_k=0,
|
54 |
+
repetition_penalty=1.1,
|
55 |
+
max_new_tokens=1024,
|
56 |
+
**kwargs,
|
57 |
+
):
|
58 |
+
prompt = generate_inference_chat_prompt(utterances, tokenizer, system_message=system_message)
|
59 |
+
input_ids = tokenizer(prompt, return_tensors="pt")["input_ids"].to(model.device)
|
60 |
+
input_length = input_ids.shape[1]
|
61 |
+
|
62 |
+
generated_outputs = model.generate(
|
63 |
+
input_ids=input_ids,
|
64 |
+
generation_config=GenerationConfig(
|
65 |
+
temperature=temperature,
|
66 |
+
do_sample=temperature > 0.0,
|
67 |
+
top_p=top_p,
|
68 |
+
top_k=top_k,
|
69 |
+
repetition_penalty=repetition_penalty,
|
70 |
+
max_new_tokens=max_new_tokens,
|
71 |
+
eos_token_id=tokenizer.eos_token_id,
|
72 |
+
pad_token_id=tokenizer.pad_token_id,
|
73 |
+
**kwargs,
|
74 |
+
),
|
75 |
+
streamer=streamer,
|
76 |
+
return_dict_in_generate=True,
|
77 |
+
)
|
78 |
+
generated_tokens = generated_outputs.sequences[0, input_length:]
|
79 |
+
generated_text = tokenizer.decode(generated_tokens, skip_special_tokens=True)
|
80 |
+
return generated_text
|
81 |
+
|
82 |
|
83 |
user_query = "Expliquez la différence entre DoS et phishing."
|
84 |
+
infer([[user_query, ""]])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
```
|
86 |
|
87 |
+
You can utilize the Google Colab Notebook below for inferring with the Vigogne chat models.
|
88 |
|
89 |
<a href="https://colab.research.google.com/github/bofenghuang/vigogne/blob/main/notebooks/infer_chat.ipynb" target="_blank"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
|
90 |
|
logo_v2.jpg
ADDED