Views
No views yet
transformers library and related dependencies. Using outdated versions may result in compatibility issues or decreased performance.transformers ≥ 4.37.0torch (with CUDA support for GPU acceleration)bitsandbytes, accelerate, peft, trl, and unsloth for specialized loading and inference1import torch
2from transformers import pipeline
3from unsloth import FastLanguageModel
4
5model_name = "KeerthiSaiKasaraneni/danish_model_primary_finetuned_model"
6
7# Load model and tokenizer
8model, tokenizer = FastLanguageModel.from_pretrained(
9 model_name=model_name,
10 load_in_4bit=True,
11 dtype=torch.float16
12)
13FastLanguageModel.for_inference(model)
14
15# Create a text generation pipeline
16generation_pipeline = pipeline(
17 "text-generation",
18 model=model,
19 tokenizer=tokenizer,
20 device_map="auto"
21)
22
23# Example instruction
24instruction = "Translate the following sentence into Danish."
25user_input = "What is the capital of Denmark?"
26prompt = f"Instruction: {instruction} Input: {user_input} Output:"
27
28generated = generation_pipeline(prompt, max_length=128, num_return_sequences=1)
29response = generated[0]['generated_text']
30print(response)
31@misc{danish_model_primary_finetuned,
title = {Danish Model Primary Finetuned},
url = {https://huggingface.co/KeerthiSaiKasaraneni/danish_model_primary_finetuned_model},
author = {[Author/Team Name]},
month = {December},
year = {2024}
}