File size: 1,304 Bytes
931f35a 3ea080c 931f35a 3ea080c |
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 |
---
license: bigscience-openrail-m
datasets:
- laion/Anh
library_name: transformers
pipeline_tag: text-generation
tags:
- pytorch
- casual-lm
- multilingual
- instruct
- bloomz
---
### Model description
This model is [`bloomz-7b1-mt`](https://huggingface.co/bigscience/bloomz-7b1-mt) model finetuned on instruct dataset `cross_lingual.jsonl` from [`laion/Anh`](https://huggingface.co/datasets/laion/Anh).
### How to use
anh-bloomz-7b1-mt-cross-lingual model can be loaded and used via the following code:
```python
import re
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"laion/anh-bloomz-7b1-mt-cross-lingual",
)
tokenizer = AutoTokenizer.from_pretrained(
"laion/anh-bloomz-7b1-mt-cross-lingual",
)
whitespace_tokens_map = {'\n': '<n>', ' ': '<w>'}
text = "User: Apa yang terjadi pada pertempuran Cannae? Jawab dalam bahasa China.\n"
for k, v in whitespace_tokens_map.items():
text = text.replace(k, v)
inputs = tokenizer(text, return_tensors="pt")
tokens = model.generate(**inputs)
output = tokenizer.decode(tokens[0], skip_special_tokens=True)
for v in whitespace_tokens_map.values():
output = re.sub(rf"{v}\s+(\S+)", rf"{v}\1", output)
for k, v in whitespace_tokens_map.items():
output = output.replace(v, k)
``` |