Views
No views yet
custom_transformer)float32xylaria_tokenizertransformers library:1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_id = "Lap1official/Xylaria-1.8"
4tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=False)
5model = AutoModelForCausalLM.from_pretrained(
6 model_id,
7 trust_remote_code=True,
8 torch_dtype=torch.float32, # Use bfloat16 if supported
9 device_map="auto" # Use if you have a GPU
10)
11
12# Example usage (generation):
13prompt = "The capital of France is"
14inputs = tokenizer(prompt, return_tensors="pt").to(model.device) # Move to GPU if available
15outputs = model.generate(**inputs, max_new_tokens=20)
16print(tokenizer.decode(outputs[0], skip_special_tokens=True))trust_remote_code=True when loading the model and tokenizer.bfloat16 (or float16 if bfloat16 is not supported) and device_map="auto" will significantly improve performance. If you do not have a GPU, you can remove those lines, but inference will be much slower.