Text Classification
Transformers
Safetensors
GGUF
English
t5
text2text-generation
cefr
language-learning
education
Instructions to use balastml/COPAL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use balastml/COPAL with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="balastml/COPAL")# Load model directly from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("balastml/COPAL") model = AutoModelForSeq2SeqLM.from_pretrained("balastml/COPAL") - llama-cpp-python
How to use balastml/COPAL with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="balastml/COPAL", filename="t5-cefr-v3-f16.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use balastml/COPAL with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf balastml/COPAL:F16 # Run inference directly in the terminal: llama cli -hf balastml/COPAL:F16
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf balastml/COPAL:F16 # Run inference directly in the terminal: llama cli -hf balastml/COPAL:F16
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf balastml/COPAL:F16 # Run inference directly in the terminal: ./llama-cli -hf balastml/COPAL:F16
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf balastml/COPAL:F16 # Run inference directly in the terminal: ./build/bin/llama-cli -hf balastml/COPAL:F16
Use Docker
docker model run hf.co/balastml/COPAL:F16
- LM Studio
- Jan
- Ollama
How to use balastml/COPAL with Ollama:
ollama run hf.co/balastml/COPAL:F16
- Unsloth Studio
How to use balastml/COPAL with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for balastml/COPAL to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for balastml/COPAL to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for balastml/COPAL to start chatting
- Atomic Chat new
- Docker Model Runner
How to use balastml/COPAL with Docker Model Runner:
docker model run hf.co/balastml/COPAL:F16
- Lemonade
How to use balastml/COPAL with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull balastml/COPAL:F16
Run and chat with the model
lemonade run user.COPAL-F16
List all available models
lemonade list
| """ | |
| T5-Base Finetuned CEFR Level Prediction Model | |
| by EmreKalkan | |
| """ | |
| import argparse | |
| import torch | |
| from transformers import T5TokenizerFast, T5ForConditionalGeneration | |
| MODEL_DIR = "." # Repo | |
| TASK_PREFIX = "classify cefr: " # DONT CHANGE IT. That is a training constant. | |
| MAX_LEN = 96 | |
| LEVELS = ["a1", "a2", "b1", "b2", "c1"] | |
| class CefrClassifier: | |
| def __init__(self, model_dir=MODEL_DIR): | |
| self.device = "cuda" if torch.cuda.is_available() else "cpu" | |
| self.tok = T5TokenizerFast.from_pretrained(model_dir, model_max_length=MAX_LEN) | |
| self.model = T5ForConditionalGeneration.from_pretrained(model_dir).to(self.device).eval() | |
| #0grad | |
| def predict(self, sentences): | |
| single = isinstance(sentences, str) | |
| if single: | |
| sentences = [sentences] | |
| enc = self.tok([TASK_PREFIX + s for s in sentences], return_tensors="pt", padding=True, truncation=True, max_length=MAX_LEN).to(self.device) | |
| gen = self.model.generate(**enc, max_length=8, num_beams=1) | |
| out = [t.strip().lower() for t in self.tok.batch_decode(gen, skip_special_tokens=True)] | |
| return out[0] if single else out | |
| def main(): | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--text", default=None) | |
| ap.add_argument("--model_dir", default=MODEL_DIR) | |
| args = ap.parse_args() | |
| clf = CefrClassifier(args.model_dir) | |
| if args.text == 1: | |
| print(f"{args.text}\n -> CEFR: {clf.predict(args.text).upper()}") | |
| return | |
| print("CEFR Prediction (for quit: q)\n") | |
| while True: | |
| try: | |
| t = input("Sentence> ").strip() | |
| except (EOFError, KeyboardInterrupt): | |
| break | |
| if t.lower() in {"q", "quit", "exit"}: | |
| break | |
| if t: | |
| print(f" -> CEFR: {clf.predict(t).upper()}\n") | |
| if __name__ == "__main__": | |
| main() | |