Efficient language modeling optimized for long sequences using the Linformer architecture. This model reduces memory and computational overhead, making it ideal for various text generation tasks.
The Linformer-based Language Model leverages the Linformer architecture to efficiently handle long sequences in text generation and other language tasks. By optimizing the self-attention mechanism, this model maintains high performance while reducing resource consumption, making it suitable for applications like text completion and generation.
Built upon the Linformer Transformer, the model incorporates several key innovations:
Install the lumenspark package via pip:
pip install lumenspark
This command installs the Linformer-based language model along with all necessary dependencies.
Below is the training loss plot that shows the progress made during the model training process:
Load the pre-trained model and tokenizer from Hugging Face to perform text generation:
from lumenspark import LumensparkModel
import torch
# 1. Set up the device (GPU if available, else CPU)
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
print(f"Using device: {device}")
# 2. Load the model and move it to the device
model = LumensparkModel.from_pretrained("anto18671/lumenspark").to(device)
# 3. Example input text
input_text = "Once upon a time"
# 4. Generate text
output_text = model.generate(
input_text,
max_length=100, # Maximum length of the generated sequence
temperature=0.7, # Controls randomness in predictions
top_k=50, # Top-k sampling to filter high-probability tokens
top_p=0.9, # Nucleus sampling to control diversity
repetition_penalty=1.2 # Penalize repetition
)
# 5. Print the generated text
print(output_text)
Customize text generation using the following parameters:
max_length: Maximum length of the generated sequence.temperature: Controls randomness (lower = more deterministic).top_k: Limits sampling to top k tokens.top_p: Nucleus sampling based on cumulative probability p.repetition_penalty: Penalizes repeated tokens or phrases.no_repeat_ngram_size: Prevents repeated n-grams of specified size.Optimized for performance and efficiency:
vocab_size: 50,257embed_dim: 768depth: 8 layersheads: 8 attention headsseq_length: 768 tokensdropout: 1/17k: 384 (attention projection)rank: 256 (low-rank projections)We would like to extend our gratitude to RunPod for their generous sponsorship, supporting the training and development of Lumenspark. Their contribution has been instrumental in pushing the project forward.
Support the ongoing development of Lumenspark!
Visit GitHub Sponsors and choose a sponsorship tier that suits you. Thank you for your support!
This project is licensed under the MIT License.
model.safetensors 429 MiBtraining_args.bin 5.1 KiBanto18671/lumenspark