Views
No views yet
Cyfieithwch y testun Saesneg canlynol i'r Gymraeg.
### Saesneg:
{prompt}
### Cymraeg:
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3device = "cuda"
4
5model = AutoModelForCausalLM.from_pretrained("BangorAI/ALMA-Cymraeg-13B-0.1", torch_dtype=torch.float16, load_in_8bit=True)
6tokenizer = AutoTokenizer.from_pretrained("BangorAI/ALMA-Cymraeg-13B-0.1")
7
8prompt = """Cyfieithwch y testun Saesneg canlynol i'r Gymraeg.
9### Saesneg:
10For the first time, GPs no longer have to physically print, sign and hand a green paper prescription form to the patient or wait for it to be taken to the pharmacy. Instead, the prescription is sent electronically from the surgery via the IT system to the patient’s chosen pharmacy - even without the patient needing to visit the surgery to pick up a repeat prescription form.
11
12### Cymraeg:
13"""
14
15model_inputs = tokenizer([prompt], return_tensors="pt").to(device)
16
17generated_ids = model.generate(**model_inputs,
18 eos_token_id=tokenizer.eos_token_id,
19 top_k=90,
20 top_p=1.0,
21 temperature=0.3,
22 repetition_penalty=1.2,
23 max_new_tokens=500,
24 do_sample=True)
25print(tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0])
26