/run_stablecode_ctransformers.py Secret
Last active
August 16, 2023 07:41
ctransformersを使ってStableCodeによるコード生成を行う
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ctransformers import AutoModelForCausalLM | |
llm = AutoModelForCausalLM.from_pretrained( | |
"TheBloke/stablecode-completion-alpha-3b-4k-GGML", | |
model_file="stablecode-completion-alpha-3b-4k.ggmlv1.q8_0.bin", | |
) | |
text = "Generate a JavaScript code to add div element" | |
inputs = "###Instruction:\n" + text + "\n\n###Response:" | |
print(inputs) | |
tokens = llm.tokenize(inputs) | |
for token in llm.generate(tokens, temperature=0.1): | |
print(llm.detokenize(token), end="") | |
print("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment