Instructions to use BangorAI/cyfieithydd-7b-fersiwn-3 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use BangorAI/cyfieithydd-7b-fersiwn-3 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="BangorAI/cyfieithydd-7b-fersiwn-3")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("BangorAI/cyfieithydd-7b-fersiwn-3") model = AutoModelForCausalLM.from_pretrained("BangorAI/cyfieithydd-7b-fersiwn-3") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use BangorAI/cyfieithydd-7b-fersiwn-3 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "BangorAI/cyfieithydd-7b-fersiwn-3" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BangorAI/cyfieithydd-7b-fersiwn-3", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/BangorAI/cyfieithydd-7b-fersiwn-3
- SGLang
How to use BangorAI/cyfieithydd-7b-fersiwn-3 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "BangorAI/cyfieithydd-7b-fersiwn-3" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BangorAI/cyfieithydd-7b-fersiwn-3", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "BangorAI/cyfieithydd-7b-fersiwn-3" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "BangorAI/cyfieithydd-7b-fersiwn-3", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use BangorAI/cyfieithydd-7b-fersiwn-3 with Docker Model Runner:
docker model run hf.co/BangorAI/cyfieithydd-7b-fersiwn-3
Cyfieithydd 7b Fersiwn 3
Model cyfieithu arbrofol sy'n defnyddio LLM Trawsnewidiol.
Mae'r model LLM yn seiliedig ar 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 wedi’u paratoi gan TechIaith
- data Hysbysiadau Llywodraeth Cymru yn archif BangorAI/hysbysiadau-llyw-cymru-1
Demo
Gallwch roi gynnig ar esiampl o'r model yma: https://demo.bangor.ai/
(cofiwch ddewis yr opsiwn "Trosi En -> Cy")
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.
- Downloads last month
- 4
