From Tarzan to Tolkien: Controlling the Language Proficiency Level of LLMs for Content Generation
Paper • 2406.03030 • Published
How to use malikali/CEFR-Aligned-LM with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="malikali/CEFR-Aligned-LM") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("malikali/CEFR-Aligned-LM")
model = AutoModelForCausalLM.from_pretrained("malikali/CEFR-Aligned-LM")How to use malikali/CEFR-Aligned-LM with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "malikali/CEFR-Aligned-LM"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "malikali/CEFR-Aligned-LM",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/malikali/CEFR-Aligned-LM
How to use malikali/CEFR-Aligned-LM with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "malikali/CEFR-Aligned-LM" \
--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": "malikali/CEFR-Aligned-LM",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "malikali/CEFR-Aligned-LM" \
--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": "malikali/CEFR-Aligned-LM",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use malikali/CEFR-Aligned-LM with Docker Model Runner:
docker model run hf.co/malikali/CEFR-Aligned-LM
This is a model card for the CEFF-Aligned Language Model (CaLM) from the paper: From Tarzan to Tolkien: Controlling the Language Proficiency Level of LLMs for Content Generation
The model text template looks like
<<Summary>>: {summary}
<<CEFR>>: {cefr}
<<Story>>:
{story}
<</Story>>
where you replace {summary} with the summary of the desired story to generate and {cefr} with the desired CEFR level is one of ["A1", "A2", "B1", "B2", "C1", "C2"].
To generate, you can add the summary and target CEFR level and just start generating after the <<Story>>:\n . See the Github repo for examples.
Base model
meta-llama/Llama-2-7b-hf