Text Generation
Transformers
PyTorch
Safetensors
llama
one-way-polyglot
japanese
english
bilingual
small-model
text-generation-inference
Instructions to use keenanpepper/one-way-polyglot-8m-tied with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use keenanpepper/one-way-polyglot-8m-tied with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="keenanpepper/one-way-polyglot-8m-tied")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("keenanpepper/one-way-polyglot-8m-tied") model = AutoModelForCausalLM.from_pretrained("keenanpepper/one-way-polyglot-8m-tied") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use keenanpepper/one-way-polyglot-8m-tied with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "keenanpepper/one-way-polyglot-8m-tied" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "keenanpepper/one-way-polyglot-8m-tied", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/keenanpepper/one-way-polyglot-8m-tied
- SGLang
How to use keenanpepper/one-way-polyglot-8m-tied 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 "keenanpepper/one-way-polyglot-8m-tied" \ --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": "keenanpepper/one-way-polyglot-8m-tied", "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 "keenanpepper/one-way-polyglot-8m-tied" \ --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": "keenanpepper/one-way-polyglot-8m-tied", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use keenanpepper/one-way-polyglot-8m-tied with Docker Model Runner:
docker model run hf.co/keenanpepper/one-way-polyglot-8m-tied
one-way-polyglot-8m-tied
A one-way polyglot language model trained to understand Japanese but generate only English.
Model Details
- Architecture: LLaMA-based transformer
- Parameters: 8,519,936 (8.5M)
- Vocabulary: 16,384 tokens (bilingual SentencePiece)
- Context Length: 512 tokens
- Embedding Strategy: Tied
Capabilities
- Semantic Transfer: Understands Japanese input and generates contextually appropriate English
- One-Way Constraint: Strong bias toward English-only generation
- Name Transliteration: Can transliterate Japanese names to English (context-dependent)
Training Data
Trained on bilingual Japanese-English story data with masked loss on Japanese prefixes to enforce one-way generation.
Usage
from transformers import LlamaForCausalLM, AutoTokenizer
model = LlamaForCausalLM.from_pretrained("one-way-polyglot-8m-tied")
tokenizer = AutoTokenizer.from_pretrained("one-way-polyglot-8m-tied")
# Japanese input β English output (primary use case)
prompt = "ζγ
γθ΅€γεγζγ£γε°ε₯³γγγΎγγγ"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=50, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
# Mixed-language name transliteration
prompt = "ε€ͺιγ―ε
¬εγ§θ±εγ¨ιγγ§γγΎγγγAfter playing, Taro told Hanako that"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=30, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
# English text (works perfectly with case folding)
prompt = "Hello World" # Automatically normalized to lowercase
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=30, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Tokenizer Features
- β Case Folding: "Hello", "hello", and "HELLO" produce identical tokenization
- β Japanese Support: Full Japanese text support with proper normalization
- β No UNK Tokens: Proper handling of uppercase/lowercase English text
- β SentencePiece Compatibility: Built using proper Unigram model with normalization
Model Variants
This is part of a series exploring one-way polyglot capabilities:
- 1.25M parameters (tied embeddings)
- 8.5M parameters (tied embeddings)
- 12.7M parameters (untied embeddings)
- 15.7M parameters (tied embeddings)
License
Apache 2.0
- Downloads last month
- -