Text Generation
PEFT
Safetensors
Transformers
lora
research-prototype
failed-promotion
not-ready-for-deployment
Instructions to use minagayid/ELLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use minagayid/ELLM with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM2-135M-Instruct") model = PeftModel.from_pretrained(base_model, "minagayid/ELLM") - Transformers
How to use minagayid/ELLM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="minagayid/ELLM")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("minagayid/ELLM", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use minagayid/ELLM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "minagayid/ELLM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "minagayid/ELLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/minagayid/ELLM
- SGLang
How to use minagayid/ELLM 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 "minagayid/ELLM" \ --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": "minagayid/ELLM", "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 "minagayid/ELLM" \ --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": "minagayid/ELLM", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use minagayid/ELLM with Docker Model Runner:
docker model run hf.co/minagayid/ELLM
Download evaluation/compare_language_models.py from minagayid/ELLM: direct link, hf CLI and curl.
- Browser
- Download file 7.42 kB
-
https://huggingface.co/minagayid/ELLM/resolve/main/evaluation/compare_language_models.py
- Command line
-
hf download hf://minagayid/ELLM/evaluation/compare_language_models.py
-
curl -L -o compare_language_models.py https://huggingface.co/minagayid/ELLM/resolve/main/evaluation/compare_language_models.py
7.42 kB
| """Compare baseline and candidate causal-LM likelihood on a frozen multilingual test corpus.""" | |
| from __future__ import annotations | |
| import argparse | |
| import gc | |
| import json | |
| import math | |
| from pathlib import Path | |
| from typing import Any | |
| from training.nlp.common import iter_jsonl, read_json, sha256_file | |
| from training.nlp.run_stage import task_data_files, validate_prepared_row | |
| def evaluate_model( | |
| model_source: str, | |
| revision: str | None, | |
| local_only: bool, | |
| data_files: list[Path], | |
| sequence_length: int, | |
| device: str, | |
| device_map: str | None, | |
| ) -> dict[str, Any]: | |
| import torch | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| tokenizer = AutoTokenizer.from_pretrained( | |
| model_source, | |
| revision=revision, | |
| trust_remote_code=False, | |
| local_files_only=local_only, | |
| ) | |
| kwargs: dict[str, Any] = { | |
| "revision": revision, | |
| "trust_remote_code": False, | |
| "use_safetensors": True, | |
| "torch_dtype": "auto", | |
| "local_files_only": local_only, | |
| } | |
| if device_map: | |
| kwargs["device_map"] = device_map | |
| model = AutoModelForCausalLM.from_pretrained(model_source, **kwargs) | |
| if not device_map: | |
| model.to(device) | |
| model.eval() | |
| totals: dict[str, dict[str, float | int]] = {} | |
| with torch.inference_mode(): | |
| for path in data_files: | |
| for line_number, row in iter_jsonl(path): | |
| validate_prepared_row(row, "evaluation", f"{path.name}:{line_number}") | |
| text = row["text"] | |
| encoded = tokenizer(text, add_special_tokens=False, return_tensors="pt")["input_ids"] | |
| if tokenizer.eos_token_id is not None: | |
| eos = torch.tensor([[tokenizer.eos_token_id]], dtype=encoded.dtype) | |
| encoded = torch.cat((encoded, eos), dim=1) | |
| if encoded.shape[1] < 2: | |
| continue | |
| if encoded.shape[1] > sequence_length: | |
| raise ValueError( | |
| f"{path.name}:{line_number} exceeds sequence_length={sequence_length}; prepare shorter evaluation records" | |
| ) | |
| input_device = model.get_input_embeddings().weight.device if device_map else device | |
| encoded = encoded.to(input_device) | |
| loss = model(input_ids=encoded, labels=encoded).loss | |
| count = int(encoded.shape[1] - 1) | |
| row_total = totals.setdefault(row["language"], { | |
| "examples": 0, "utf8_bytes": 0, "predicted_tokens": 0, "negative_log_likelihood_nats": 0.0, | |
| }) | |
| row_total["examples"] += 1 | |
| row_total["utf8_bytes"] += len(text.encode("utf-8")) | |
| row_total["predicted_tokens"] += count | |
| row_total["negative_log_likelihood_nats"] += float(loss) * count | |
| metrics = {} | |
| for language, totals_for_language in sorted(totals.items()): | |
| byte_count = int(totals_for_language["utf8_bytes"]) | |
| nll = float(totals_for_language["negative_log_likelihood_nats"]) | |
| metrics[language] = { | |
| **totals_for_language, | |
| "bits_per_byte": nll / (byte_count * math.log(2)) if byte_count else None, | |
| "nats_per_token": nll / int(totals_for_language["predicted_tokens"]), | |
| } | |
| del model, tokenizer | |
| gc.collect() | |
| if torch.cuda.is_available(): | |
| torch.cuda.empty_cache() | |
| return metrics | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--manifest", type=Path, required=True, help="Frozen evaluation-purpose manifest, test split only") | |
| parser.add_argument("--candidate", type=Path, required=True, help="Locally saved model candidate") | |
| parser.add_argument("--baseline-id", required=True) | |
| parser.add_argument("--baseline-revision", required=True, help="Full pinned model commit") | |
| parser.add_argument("--sequence-length", type=int, default=2048) | |
| parser.add_argument("--device", default="auto", help="Model device when --device-map is omitted") | |
| parser.add_argument("--device-map", help="Optional Transformers device map, such as auto") | |
| parser.add_argument("--output", type=Path, required=True) | |
| args = parser.parse_args() | |
| if args.sequence_length < 2: | |
| raise ValueError("sequence-length must be at least 2") | |
| device = args.device | |
| if device == "auto": | |
| import torch | |
| device = "cuda" if torch.cuda.is_available() else "cpu" | |
| if len(args.baseline_revision) != 40 or any(char not in "0123456789abcdef" for char in args.baseline_revision): | |
| raise ValueError("baseline-revision must be a full 40-character commit SHA") | |
| manifest_path = args.manifest.resolve() | |
| manifest = read_json(manifest_path) | |
| if manifest.get("schema_version") != 1 or manifest.get("purpose") != "evaluation": | |
| raise ValueError("evaluation requires a prepared schema-v1 evaluation manifest") | |
| if int(manifest.get("splits", {}).get("test", {}).get("rows", 0)) < 1: | |
| raise ValueError("frozen evaluation test split is empty") | |
| paths = task_data_files(manifest_path, manifest, "test") | |
| for entry, path in zip(manifest["splits"]["test"]["files"], paths): | |
| if not entry.get("sha256") or sha256_file(path) != entry["sha256"]: | |
| raise ValueError(f"frozen evaluation shard hash mismatch: {path.name}") | |
| candidate = args.candidate.resolve() | |
| if not candidate.is_dir() or not (candidate / "config.json").is_file(): | |
| raise ValueError("candidate must be a local Transformers model directory with config.json") | |
| output = args.output.resolve() | |
| if output.exists(): | |
| raise FileExistsError(f"refusing to overwrite evaluation report: {output}") | |
| baseline_metrics = evaluate_model( | |
| args.baseline_id, args.baseline_revision, False, paths, args.sequence_length, device, args.device_map | |
| ) | |
| candidate_metrics = evaluate_model( | |
| str(candidate), None, True, paths, args.sequence_length, device, args.device_map | |
| ) | |
| candidate_run = candidate / "candidate-run.json" | |
| report = { | |
| "schema_version": 1, | |
| "evaluation": "frozen multilingual causal-LM likelihood comparison", | |
| "evaluation_manifest": str(manifest_path), | |
| "evaluation_manifest_sha256": sha256_file(manifest_path), | |
| "baseline": {"model_id": args.baseline_id, "revision": args.baseline_revision, "metrics_by_language": baseline_metrics}, | |
| "candidate": { | |
| "path": str(candidate), | |
| "run_manifest_sha256": sha256_file(candidate_run) if candidate_run.is_file() else None, | |
| "metrics_by_language": candidate_metrics, | |
| }, | |
| "limitations": [ | |
| "bits per byte is a language-model likelihood diagnostic, not a measure of helpfulness, factuality, reasoning, safety, or generation quality", | |
| "Arabic and other language scores are meaningful only when the frozen test corpus contains sufficient independently reviewed examples", | |
| "this report cannot promote or publish a candidate", | |
| ], | |
| } | |
| output.parent.mkdir(parents=True, exist_ok=True) | |
| output.write_text(json.dumps(report, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") | |
| print(json.dumps({"output": str(output), "languages": sorted(set(baseline_metrics) & set(candidate_metrics))})) | |
| if __name__ == "__main__": | |
| main() | |