bofenghuang
commited on
Commit
•
fb9cd31
1
Parent(s):
f777802
Add README
Browse files
README.md
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: openrail
|
3 |
+
language:
|
4 |
+
- fr
|
5 |
+
pipeline_tag: text-generation
|
6 |
+
library_name: transformers
|
7 |
+
tags:
|
8 |
+
- LLM
|
9 |
+
inference: false
|
10 |
+
---
|
11 |
+
|
12 |
+
<p align="center" width="100%">
|
13 |
+
<img src="https://huggingface.co/bofenghuang/vigogne-mpt-7b-instruct/resolve/main/vigogne_logo.png" alt="Vigogne" style="width: 40%; min-width: 300px; display: block; margin: auto;">
|
14 |
+
</p>
|
15 |
+
|
16 |
+
# Vigogne-MPT-7B-Instruct: A French Instruction-following MPT Model
|
17 |
+
|
18 |
+
Vigogne-MPT-7B-Instruct is a [MPT-7B](https://huggingface.co/mosaicml/mpt-7b) model fine-tuned to follow the French instructions.
|
19 |
+
|
20 |
+
For more information, please visit the Github repo: https://github.com/bofenghuang/vigogne
|
21 |
+
|
22 |
+
## Usage
|
23 |
+
|
24 |
+
```python
|
25 |
+
import torch
|
26 |
+
from transformers import AutoConfig, AutoModelForCausalLM, AutoTokenizer, GenerationConfig
|
27 |
+
from vigogne.preprocess import generate_instruct_prompt
|
28 |
+
|
29 |
+
model_name_or_path = "bofenghuang/vigogne-mpt-7b-instruct"
|
30 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path)
|
31 |
+
config = AutoConfig.from_pretrained(model_name_or_path, trust_remote_code=True)
|
32 |
+
# config.attn_config['attn_impl'] = 'triton'
|
33 |
+
config.init_device = 'cuda:0' # For fast initialization directly on GPU!
|
34 |
+
|
35 |
+
model = AutoModelForCausalLM.from_pretrained(
|
36 |
+
model_name_or_path,
|
37 |
+
config=config,
|
38 |
+
torch_dtype=torch.float16,
|
39 |
+
device_map="auto",
|
40 |
+
trust_remote_code=True,
|
41 |
+
)
|
42 |
+
|
43 |
+
user_query = "Expliquez la différence entre DoS et phishing."
|
44 |
+
prompt = generate_instruct_prompt(user_query)
|
45 |
+
input_ids = tokenizer(prompt, return_tensors="pt")["input_ids"].to(model.device)
|
46 |
+
input_length = input_ids.shape[1]
|
47 |
+
|
48 |
+
generated_outputs = model.generate(
|
49 |
+
input_ids=input_ids,
|
50 |
+
generation_config=GenerationConfig(
|
51 |
+
temperature=0.1,
|
52 |
+
do_sample=True,
|
53 |
+
repetition_penalty=1.0,
|
54 |
+
max_new_tokens=512,
|
55 |
+
),
|
56 |
+
return_dict_in_generate=True,
|
57 |
+
pad_token_id=tokenizer.eos_token_id,
|
58 |
+
)
|
59 |
+
generated_tokens = generated_outputs.sequences[0, input_length:]
|
60 |
+
generated_text = tokenizer.decode(generated_tokens, skip_special_tokens=True)
|
61 |
+
print(generated_text)
|
62 |
+
```
|
63 |
+
|
64 |
+
You can also infer this model by using the following Google Colab Notebook.
|
65 |
+
|
66 |
+
<a href="https://colab.research.google.com/github/bofenghuang/vigogne/blob/main/notebooks/infer_instruct.ipynb" target="_blank"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
|
67 |
+
|
68 |
+
## Limitations
|
69 |
+
|
70 |
+
Vigogne is still under development, and there are many limitations that have to be addressed. Please note that it is possible that the model generates harmful or biased content, incorrect information or generally unhelpful answers.
|