Translation
Transformers
Safetensors
llama
text-generation
multilingual
lora
astheraltranslate
text-generation-inference
Instructions to use SEE7/AstheralTranslate with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SEE7/AstheralTranslate with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("translation", model="SEE7/AstheralTranslate")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("SEE7/AstheralTranslate") model = AutoModelForCausalLM.from_pretrained("SEE7/AstheralTranslate", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 1,561 Bytes
2c5fc66 | 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 | from pathlib import Path
from playwright.sync_api import sync_playwright
import json
with sync_playwright() as p:
b=p.chromium.launch(headless=True,args=['--no-sandbox'])
page=b.new_page(ignore_https_errors=True);errors=[];page.on('pageerror',lambda e:errors.append(str(e)))
script=Path('/tmp/translate_ui.js').read_text()
page.route('**/model-manager.js',lambda r:r.fulfill(status=200,content_type='application/javascript',body=script))
captured=[]
def respond(r):
captured.append(r.request.post_data_json)
event={'choices':[{'index':0,'delta':{'content':'Test translation'},'finish_reason':None}]}
r.fulfill(status=200,content_type='text/event-stream',body='data: '+json.dumps(event)+'\n\ndata: [DONE]\n\n')
page.route('**/v1/chat/completions',respond)
page.goto('https://see7-astheral.hf.space/',wait_until='networkidle',timeout=30000)
for name in ['German','French','Spanish','Italian','Portuguese']:
page.get_by_label('Target language',exact=True).select_option(name)
area=page.locator('textarea').filter(visible=True).first
area.fill('Good morning.')
page.get_by_role('button',name='Send',exact=True).click()
page.wait_for_timeout(500)
assert captured[-1]['model']=='SEE7/AstheralTranslate'
assert captured[-1]['messages'][-1]['content'].startswith('[Target: '+name+']')
page.reload(wait_until='networkidle')
assert page.get_by_label('Target language',exact=True).input_value()=='Portuguese'
print('PASS: all five target selections, correct model routing, persisted selection; browser errors',errors,flush=True)
b.close()
|