Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
2
3model = AutoModelForCausalLM.from_pretrained("alexvumnov/yaml_completion")
4tokenizer = AutoTokenizer.from_pretrained("alexvumnov/yaml_completion", padding='left')
5
6prompt_format = """
7# Here's a yaml file to offer a completion for
8# Lines after the current one
9{text_after}
10# Lines before the current one
11{text_before}
12# Completion:
13"""
14
15input_prefix = """
16name: my_awesome_env
17dependencies:
18
19"""
20
21input_suffix = ""
22
23generator = pipeline('text-generation', model=model, tokenizer=tokenizer, device='cuda')
24
25generator(prompt_format.format(text_after=input_suffix, text_before=input_prefix), max_new_tokens=64)
26
27# [{'generated_text': "\n# Here's a yaml file to offer a completion for\n# Lines after the current one\n\n# Lines before the current one\n\nname: my_awesome_env\ndependencies:\n\n\n# Completion:\n- deploy"}]