Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the prompt should be refined #5

Open
tongsir opened this issue Nov 13, 2024 · 0 comments
Open

the prompt should be refined #5

tongsir opened this issue Nov 13, 2024 · 0 comments

Comments

@tongsir
Copy link

tongsir commented Nov 13, 2024

to you handsome guys.
the prompt in this demo maybe not working as the author said, the output is excessive because of bad format of the prompt, as mentioned here, and i followed that answer, using huggingface-chat-template, and the output is ok.

below is my solution.

>>> messages = [
...     {"role": "system", "content": "Convert the following SQL written in Oracle dialect to MySQL dialect. only SQL is allowed in response"},
...     {"role": "user", "content": "SELECT col1, TRUNC (col2/20) 'c2', TO_DATE(SYSDATE) 'c3' FROM ttt WHERE col3=4"},
... ]
>>>
>>>
>>> tokenized_chat = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
>>> print(tokenizer.decode(tokenized_chat[0]))
<s> [INST] <<SYS>>
Convert the following SQL written in Oracle dialect to MySQL dialect. only SQL is allowed in response
<</SYS>>

SELECT col1, TRUNC (col2/20) 'c2', TO_DATE(SYSDATE) 'c3' FROM ttt WHERE col3=4 [/INST]
>>> outputs = model.generate(tokenized_chat, max_new_tokens=1280)
The attention mask and the pad token id were not set. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Setting `pad_token_id` to `eos_token_id`:None for open-end generation.
>>> print(tokenizer.decode(outputs[0]))
<s> [INST] <<SYS>>
Convert the following SQL written in Oracle dialect to MySQL dialect. only SQL is allowed in response
<</SYS>>

SELECT col1, TRUNC (col2/20) 'c2', TO_DATE(SYSDATE) 'c3' FROM ttt WHERE col3=4 [/INST]  SELECT col1, TRUNC(col2/20) AS c2, CURDATE() AS c3 FROM ttt WHERE col3=4;</s>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant