Loïck commited on
Commit ·
0905d7b
1
Parent(s): dbab184
Update README.md
Browse files
README.md
CHANGED
|
@@ -6,6 +6,69 @@ base_model:
|
|
| 6 |
pipeline_tag: summarization
|
| 7 |
datasets:
|
| 8 |
- CATIE-AQ/frenchSUM
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
pipeline_tag: summarization
|
| 7 |
datasets:
|
| 8 |
- CATIE-AQ/frenchSUM
|
| 9 |
+
license_name: lfm1.0
|
| 10 |
---
|
| 11 |
|
| 12 |
+
## Description
|
| 13 |
+
Liquid.AI's [LFM2](https://huggingface.co/LiquidAI/LFM2-1.2B) model finetuned on [frenchSUM]([hf.co/CATIE-AQ/frenchSUM](https://huggingface.co/datasets/CATIE-AQ/frenchSUM)) dataset to summarize French texts in ~32 words.
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
## Usage
|
| 17 |
+
|
| 18 |
+
```python
|
| 19 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 20 |
+
|
| 21 |
+
model_id = "CATIE-AQ//LMF2_french_summary"
|
| 22 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 23 |
+
model_id,
|
| 24 |
+
device_map="auto",
|
| 25 |
+
torch_dtype="bfloat16",
|
| 26 |
+
trust_remote_code=True,
|
| 27 |
+
# attn_implementation="flash_attention_2" <- uncomment on compatible GPU
|
| 28 |
+
)
|
| 29 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
prompt = """Résume l'article suivant :\n""" + "text_to_summarize"
|
| 33 |
+
tokenizer.padding_side = "left"
|
| 34 |
+
tokenizer.truncation_side = "right"
|
| 35 |
+
|
| 36 |
+
# Apply the chat template to prepare the input
|
| 37 |
+
input_ids = tokenizer.apply_chat_template(
|
| 38 |
+
[{"role": "user", "content": prompt}],
|
| 39 |
+
add_generation_prompt=True,
|
| 40 |
+
return_tensors="pt",
|
| 41 |
+
tokenize=True,
|
| 42 |
+
).to(model.device)
|
| 43 |
+
|
| 44 |
+
# Generate the output from the model
|
| 45 |
+
output = model.generate(
|
| 46 |
+
input_ids,
|
| 47 |
+
do_sample=True,
|
| 48 |
+
temperature=0.3,
|
| 49 |
+
min_p=0.15,
|
| 50 |
+
repetition_penalty=1.05,
|
| 51 |
+
max_new_tokens=2048,
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
summary_text = tokenizer.decode(
|
| 55 |
+
output[0][input_ids.shape[1]:], # Slice the output tensor
|
| 56 |
+
skip_special_tokens=True # Skip special tokens for a cleaner output
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
print(summary_text)
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
## Results
|
| 63 |
+
|
| 64 |
+
#### orange_sum test split
|
| 65 |
+
|
| 66 |
+
| Model | Parameters | ROUGE-1 | ROUGE-2 | ROUGE-L |
|
| 67 |
+
|--------------------------------------|-------------|----------|----------|----------|
|
| 68 |
+
| LMF2_french_summary (this model) | 1.2B | | | |
|
| 69 |
+
| [Barthez](https://huggingface.co/moussaKam/barthez) | 165M | 31.44 | 12.77 | 22.23 |
|
| 70 |
+
| [mBarthez](https://huggingface.co/moussaKam/mbarthez) | 458M | 32.67 | 13.73 | 23.18 |
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
## License
|
| 74 |
+
[LMF1.0](https://huggingface.co/LiquidAI/LFM2-1.2B/blob/main/LICENSE)
|