Text Generation
Transformers
PyTorch
Welsh
mistral
text-generation-inference
Inference Endpoints
rhysjones commited on
Commit
1c7bb4c
1 Parent(s): a0be022

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +70 -0
README.md CHANGED
@@ -1,3 +1,73 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ datasets:
4
+ - techiaith/cofnodycynulliad_en-cy
5
+ - BangorAI/hysbysiadau-llyw-cymru-1
6
+ language:
7
+ - cy
8
  ---
9
+
10
+ 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.
11
+
12
+ Cafodd y model hyfforddiant cywrain pellach ar y cyfeithiadau canlynol:
13
+ * data [Cofnod y Cynulliad](https://huggingface.co/techiaith/cofnodycynulliad_en-cy) wedi’u paratoi gan [TechIaith](https://huggingface.co/techiaith)
14
+ * data [Hysbysiadau Llywodraeth Cymru](https://www.llyw.cymru/hysbysiadau) yn archif [BangorAI/hysbysiadau-llyw-cymru-1](https://huggingface.co/BangorAI/hysbysiadau-llyw-cymru-1)
15
+
16
+ ## Demo
17
+
18
+ Gallwch roi gynnig ar esiampl o'r model yma: [https://demo.bangor.ai/](https://demo.bangor.ai/)
19
+
20
+ ### Fformat Sgwrs
21
+
22
+ Mae'r hyfforddiant cywrain wedi defnyddio'r fformat canlynol ar gyfer trosi o'r Saesneg i'r Gymraeg:
23
+ ```
24
+ Cyfieithwch y testun Saesneg canlynol i'r Gymraeg.
25
+ ### Saesneg:
26
+ {prompt}
27
+
28
+ ### Cymraeg:
29
+
30
+ ```
31
+
32
+ a'r naill ffordd i'r llall:
33
+ ```
34
+ Translate the following Welsh text to English.
35
+ ### Welsh:
36
+ {prompt}
37
+
38
+ ### English:
39
+
40
+ ```
41
+
42
+ ## Sut i'w ddefnyddio
43
+
44
+ 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.
45
+
46
+ Dyma enghraifft mewn Python:
47
+
48
+ ```
49
+ import transformers
50
+
51
+ device="cuda"
52
+ model_name = 'BangorAI/cyfieithydd-7b-fersiwn-3'
53
+ model = transformers.AutoModelForCausalLM.from_pretrained(model_name, load_in_8bit=True)
54
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_name)
55
+
56
+ def generate_response(text):
57
+ # Format the input using the provided template
58
+ prompt = f"Cyfieithwch y testun Saesneg canlynol i'r Gymraeg.\n\n### Saesneg:\n{text}\n\n### Cymraeg:\n"
59
+ # Tokenize and encode the prompt
60
+ inputs = tokenizer.encode(prompt, return_tensors="pt", add_special_tokens=False).to(device)
61
+ # Generate a response
62
+ outputs = model.generate(inputs, max_length=1000, num_return_sequences=1, do_sample=True, temperature=0.01)
63
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
64
+ return response
65
+
66
+ 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."""
67
+ response = generate_response(text)
68
+ print(response)
69
+
70
+ ```
71
+
72
+ ## Hawlfraint
73
+ 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/).