|
--- |
|
license: apache-2.0 |
|
datasets: |
|
- techiaith/cofnodycynulliad_en-cy |
|
- BangorAI/hysbysiadau-llyw-cymru-1 |
|
language: |
|
- cy |
|
--- |
|
|
|
Mae'r model LLM yn seiliedig ar [BangorAI/mistral-7b-cy-epoch-2](https://huggingface.co/BangorAI/mistral-7b-cy-epoch-2), sef y model Mistral-7B wedi hyfforddiant parhaus ar gyfer y Gymraeg. |
|
|
|
Cafodd y model hyfforddiant cywrain pellach ar y cyfeithiadau canlynol: |
|
* data [Cofnod y Cynulliad](https://huggingface.co/techiaith/cofnodycynulliad_en-cy) wedi’u paratoi gan [TechIaith](https://huggingface.co/techiaith) |
|
* data [Hysbysiadau Llywodraeth Cymru](https://www.llyw.cymru/hysbysiadau) yn archif [BangorAI/hysbysiadau-llyw-cymru-1](https://huggingface.co/BangorAI/hysbysiadau-llyw-cymru-1) |
|
|
|
## Demo |
|
|
|
Gallwch roi gynnig ar esiampl o'r model yma: [https://demo.bangor.ai/](https://demo.bangor.ai/) |
|
|
|
### Fformat Sgwrs |
|
|
|
Mae'r hyfforddiant cywrain wedi defnyddio'r fformat canlynol ar gyfer trosi o'r Saesneg i'r Gymraeg: |
|
``` |
|
Cyfieithwch y testun Saesneg canlynol i'r Gymraeg. |
|
### Saesneg: |
|
{prompt} |
|
|
|
### Cymraeg: |
|
|
|
``` |
|
|
|
a'r naill ffordd i'r llall: |
|
``` |
|
Translate the following Welsh text to English. |
|
### Welsh: |
|
{prompt} |
|
|
|
### English: |
|
|
|
``` |
|
|
|
## Sut i'w ddefnyddio |
|
|
|
Mae'r model Mistral-7B-v-0.1 sy'n tanseilio'r model yma yn defnyddio ffenestr cyd-destun maint 4k, felly mae'n ofyniad i becynnu'r testyn fesul paragraff a'u bwydo i mewn i'r LLM yn eu tro. |
|
|
|
Dyma enghraifft mewn Python: |
|
|
|
``` |
|
import transformers |
|
|
|
device="cuda" |
|
model_name = 'BangorAI/cyfieithydd-7b-fersiwn-3' |
|
model = transformers.AutoModelForCausalLM.from_pretrained(model_name, load_in_8bit=True) |
|
tokenizer = transformers.AutoTokenizer.from_pretrained(model_name) |
|
|
|
def generate_response(text): |
|
# Format the input using the provided template |
|
prompt = f"Cyfieithwch y testun Saesneg canlynol i'r Gymraeg.\n\n### Saesneg:\n{text}\n\n### Cymraeg:\n" |
|
# Tokenize and encode the prompt |
|
inputs = tokenizer.encode(prompt, return_tensors="pt", add_special_tokens=False).to(device) |
|
# Generate a response |
|
outputs = model.generate(inputs, max_length=1000, num_return_sequences=1, do_sample=True, temperature=0.01) |
|
response = tokenizer.decode(outputs[0], skip_special_tokens=True) |
|
return response |
|
|
|
text="""The extension of the Flying Start programme is part of a phased expansion of early years provision to all two-year-olds in Wales, with a particular emphasis on strengthening Welsh-medium provision. This is a commitment in the Co-operation Agreement between the Welsh Government and Plaid Cymru.""" |
|
response = generate_response(text) |
|
print(response) |
|
|
|
``` |
|
|
|
## Hawlfraint |
|
Mae'r data Cofnod y Cynulliad ac Hysbysiadau Llywodreath Cymru dan [Drwydded Llywodraeth Agored](https://www.nationalarchives.gov.uk/doc/open-government-licence-cymraeg/version/3/). |