Created
October 5, 2023 04:37
-
-
Save bddppq/9eceedf5c13c45df4df1ec35d0309331 to your computer and use it in GitHub Desktop.
elyza-jp-llama2-7b
This file contains hidden or 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
import openai | |
openai.api_base = "https://elyza-jp-llama2-7b.lepton.run/api/v1" | |
openai.api_key = "YOUR_API_KEY" | |
B_INST, E_INST = "[INST]", "[/INST]" | |
B_SYS, E_SYS = "<<SYS>>\n", "\n<</SYS>>\n\n" | |
DEFAULT_SYSTEM_PROMPT = "あなたは誠実で優秀な日本人のアシスタントです。" | |
BOS_TOKEN = "<s>" | |
text = "クマが海辺に行ってアザラシと友達になり、最終的には家に帰るというプロットの短編小説を書いてください。" | |
prompt = "{bos_token}{b_inst} {system}{prompt} {e_inst} ".format( | |
bos_token=BOS_TOKEN, | |
b_inst=B_INST, | |
system=f"{B_SYS}{DEFAULT_SYSTEM_PROMPT}{E_SYS}", | |
prompt=text, | |
e_inst=E_INST, | |
) | |
print("===============PROMPT===================") | |
print(prompt) | |
print("===============ANSWER===================") | |
completion = openai.Completion.create( | |
model="elyza-jp-llama2-7b", # can be "gpt-3.5-turbo" as well | |
prompt=prompt, | |
max_tokens=512, | |
stream=True, | |
) | |
for comp in completion: | |
text = comp["choices"][0]["text"] | |
print(text, end="") | |
print("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment