Views
No views yet
1import torch
2from transformers import pipeline, AutoTokenizer
3
4question = "Write a Python function that takes a list of numbers and returns the list sorted in ascending order without using the built-in `sorted()` function. Return ONLY code in your output. ###Python code:"
5generator = pipeline("text-generation", model="mariasandu/python-coding-assistant-v2", device="cuda")
6
7tokenizer = AutoTokenizer.from_pretrained("mariasandu/python-coding-assistant-v2")
8tokenizer.chat_template = "{% for message in messages %}{% if message['role'] == 'user' %}[INST] {{ message['content'] }} [/INST]{% else %}{{ message['content'] }}{% endif %}{% endfor %}"
9output = generator(question)[0]
10print(output['generated_text'])1@misc{vonwerra2022trl,
2 title = {{TRL: Transformer Reinforcement Learning}},
3 author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
4 year = 2020,
5 journal = {GitHub repository},
6 publisher = {GitHub},
7 howpublished = {\url{https://github.com/huggingface/trl}}
8}