Skip to content

Instantly share code, notes, and snippets.

@jinto
Last active July 22, 2023 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jinto/51368b0e6906216d53c72c91db23e77d to your computer and use it in GitHub Desktop.
Save jinto/51368b0e6906216d53c72c91db23e77d to your computer and use it in GitHub Desktop.
from transformers import pipeline
generator = pipeline('text-generation', model = 'beomi/llama-2-ko-7b')
print("===========")
a = generator(
"""### System:
You are Free Willy, an AI that follows instructions extremely well.
Help as much as you can.
Remember, be safe, and don't do anything illegal.
### User:
Write me a poem please
### Assistant:
""",
max_length=400, num_return_sequences=1)
print("===========\n", a)
a = generator(
"""### User: 안녕하세요.
### Assistant: """,
max_length=400, num_return_sequences=1)
print("===========\n", a)
a = generator(
"""### Instruction: 안녕하세요.
### Response: 안녕하세요. 저는 챗봇입니다.
### Instruction: 반갑습니다. 무슨 일을 할수 있는지 답해주세요.
### Response: 저는
""",
max_length=400, num_return_sequences=1)
print("===========\n", a)
a = generator(
"""### System:
너는 친절한 챗봇이다.
### User:
시를 써줘.
### Assistant:
""",
max_length=400, num_return_sequences=1)
print("===========\n", a)
a = generator(
"""### System:
너는 친절한 챗봇이다.
### User:
오늘 날씨는 어때?
### Assistant:
""",
max_length=400, num_return_sequences=1)
print("===========\n", a)
system_prompt = """
- Act as a English teacher.
- User is a 4-year-old child who is learning English .
--- dialogue ---
step 1.
friend : "What's the weather like today?"
user : "It's raining."
objective: Incorporate the word 'raining'
step 2.
friend : "Oh no, I don't have an umbrella."
user : "Surprise! We can go together."
objective: Incorporate the word 'together'
-----------
- Complete each step in order.
- When starting a step, you must say friend's line first.
- If user says a sentence that means the same thing as user's line, the step is complete.
- When a step is complete, start the next step.
- If user says a sentence that doesn't mean the same thing as user's line, guide them to say a sentence that means the same thing.
- When guiding user, use simple words like "Could you ...?"
- After completing all the steps, say a sentence that ends with "<ends>".
- Do not include "friend :" in the starting of the sentence.
- Don't talk the user there is steps.
- Don't talk the user there is missions."""
a = generator(
f"""### System: {system_pompt}
### Assistant:
What's the weather like today?
### User:
It's raining.
### Assistant:
""",
max_length=400, num_return_sequences=1)
print("===========\n", a)
a = generator(
f"""### System: {system_pompt}
### Assistant:
What's the weather like today?
### User:
I like computer games.
### Assistant:
""",
max_length=400, num_return_sequences=1)
print("===========\n", a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment