Views
No views yet
TinyLlama/TinyLlama-1.1B-Chat-v1.0 using a subset of Python code from the codeparrot dataset. It is trained to generate Python functions and code snippets based on natural language or code-based prompts.TinyLlama/TinyLlama-1.1B-Chat-v1.0codeparrot/codeparrot-clean-valid[:1000]1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3
4base_model = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
5adapter_model = "your-username/tinyllama-python-lora"
6
7tokenizer = AutoTokenizer.from_pretrained(base_model)
8model = AutoModelForCausalLM.from_pretrained(base_model)
9model = PeftModel.from_pretrained(model, adapter_model)
10
11prompt = "<|python|>\ndef fibonacci(n):"
12inputs = tokenizer(prompt, return_tensors="pt")
13outputs = model.generate(**inputs, max_new_tokens=100)
14print(tokenizer.decode(outputs[0], skip_special_tokens=True))