Downloads · 30 days
5
2% of all-time downloads
guaran-ia/coreguapa-lm
coreguapa-lm is a text generation model from guaran-ia. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as gpl-3.0.
This model is intended to be used to validate the quality of Guarani text. It was trained on the COREGUAPA corpus, a restricted dataset manually compiled and curated by the Paraguayan Secretary of Linguistic Policies.…
Downloads · 30 days
5
2% of all-time downloads
All-time downloads
303
Public
Parameters
9.2B
18.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors18.5 GB · 100%
From the Hugging Face model README
This model is intended to be used to validate the quality of Guarani text. It was trained on the COREGUAPA corpus, a restricted dataset manually compiled and curated by the Paraguayan Secretary of Linguistic Policies. The corpus contains high-quality documents, including primarily copyrighted materials.
⚠️ Although the model is based on a transformer-based architecture (Gemma2-9b-it), it was not developed as a generative tool — its primary use is to compute the perplexity score of Guarani documents. Lower perplexity may indicate text that is more predictable by the model and more similar to the reference high-quality corpus.
princeton-nlp/gemma-2-9b-it-SimPOGemma2ForCausalLM42358416143362560008192 tokensfloat16tokenizer.json and tokenizer_config.jsongeneration_config.jsonchat_template.jinja112e-50.01100paged_adamw_8bitlinear6bf162048892 records (1826816 tokens)111 records (227328 tokens)112 records (229376 tokens)princeton-nlp/gemma-2-9b-it-SimPOCompute perplexity for a given Guarani text using the fine-tuned model:
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
import math
model_id = 'guaran-ia/coreguapa-lm'
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id)
model.eval()
def perplexity(text: str) -> float:
inputs = tokenizer(text, return_tensors='pt')
with torch.no_grad():
outputs = model(**inputs, labels=inputs['input_ids'])
loss = outputs.loss
return math.exp(loss.item())
text = "Your Guarani text here."
print(f"Perplexity: {perplexity(text):.4f}")
If input length exceeds the model/tokenizer maximum (8192 tokens), you can follow the next recipe to compute perplexity over sliding chunks and average per-token loss.
import torch, math
def perplexity_sliding(text: str, model, tokenizer, max_len: int = 8192, stride: int = 4096):
"""Compute perplexity over long text by slicing into overlapping chunks.
- `max_len` should be <= model.config.max_position_embeddings (8192).
- `stride` controls overlap; larger overlap gives smoother per-token averaging.
"""
enc = tokenizer(text, return_tensors='pt')['input_ids'][0]
n = enc.size(0)
if n == 0:
return float('nan')
total_nll = 0.0
total_tokens = 0
start = 0
while start < n:
end = min(start + max_len, n)
input_ids = enc[start:end].unsqueeze(0)
with torch.no_grad():
outputs = model(input_ids, labels=input_ids)
# outputs.loss is the average NLL for the chunk
loss = outputs.loss.item()
chunk_len = end - start
total_nll += loss * chunk_len
total_tokens += chunk_len
if end == n:
break
start += stride
avg_nll = total_nll / total_tokens
return math.exp(avg_nll)
# Example usage:
text = open('some_guarani.txt', encoding='utf-8').read()
tokenizer.model_max_length = 8192
print(f"Perplexity (sliding): {perplexity_sliding(text, model, tokenizer):.4f}")
This model checkpoint and accompanying files are released under the GNU General Public License v3 (GPLv3).
See the LICENSE file in this directory for the full license text.