Spaces:
Runtime error

File size: 721 Bytes
218e3c2
1c8bd9c
218e3c2
1c8bd9c
218e3c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
370708c
218e3c2
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline

MODEL_NAME = "microsoft/Phi-3-mini-4k-instruct"

# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
model = AutoModelForCausalLM.from_pretrained(
    MODEL_NAME,
    device_map="auto",      # puts model on GPU if available
    torch_dtype="auto"      # chooses best precision
)

# Create text-generation pipeline
pipe = pipeline(
    "text-generation",
    model=model,
    tokenizer=tokenizer
)

# Prompt for testing
prompt = "Explain the concept of cricket in simple terms."

# Generate response
output = pipe(prompt, max_new_tokens=200, do_sample=True, temperature=0.7, top_p=0.9)
print(output[0]["generated_text"])