mirror of
https://github.com/deepseek-ai/DeepSeek-Coder.git
synced 2026-11-05 00:57:19 +00:00
[GH-ISSUE #71] FIM doesn't work #58
Labels
No labels
documentation
ENV
pull-request
research question
WIP
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepSeek-Coder#58
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SinanAkkoyun on GitHub (Dec 6, 2023).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-Coder/issues/71
Fill in the middle is performing very badly for me
prompt:
Response:
However, without FIM tokens:
This is just an example, it doesn't work for large code either, neither for the 1.3B, 6.7B nor 33B
I also already checked, the special tokens get encoded right
Am I doing something wrong?
@pkuzqh commented on GitHub (Dec 7, 2023):
I use this code to run the fim mode, and it outputs
Does your library transformers have the correct version?
@SinanAkkoyun commented on GitHub (Dec 7, 2023):
Thank you for testing! I really don't know why, but when I try it out now (I was and am using ExllamaV2 with GPTQ), the 6.7B model gets the prediction right...
I believe now that I copied your top_p it works wonders
May I ask what sampling parameters work best for the model? I have seen that having a rep. penalty of 1.15 for example strongly degrades output quality for whatever reason
It would be awesome to know the best settings :)
@SinanAkkoyun commented on GitHub (Dec 7, 2023):
Oh and also I have seen the 33B model produce
<|end▁of▁sentence|> and <|end▁of▁sentence|>, should any of these be used in a specific way for instruction and or code completion?
@pkuzqh commented on GitHub (Dec 7, 2023):
actually, you can just use do_sample=False, repetition_penalty=1. Here top_p is not worked.
@pkuzqh commented on GitHub (Dec 7, 2023):
for code completion, you can use <|end▁of▁sentence|> as eos, for instruction model, you can use <|EOT|>
@SinanAkkoyun commented on GitHub (Dec 7, 2023):
Oh, greedy sampling is recommended for the model?
Regarding the <|begin▁of▁sentence|> (sorry for the typo before), should I use that at every start of conversation or at every new instruction/response turn?
@pkuzqh commented on GitHub (Dec 7, 2023):
No! You just need add the bos token before the first turn
@SinanAkkoyun commented on GitHub (Dec 7, 2023):
Oh so
?
And also no sampling in recommended, even for 33B?
Thank you so much :)
@pkuzqh commented on GitHub (Dec 7, 2023):
bos"System prompt"
Instruction:
...
Response:
...
etc
yeah, you can use greedy search for models.
@SinanAkkoyun commented on GitHub (Dec 7, 2023):
Ok last two questions, is the bos recommended for the base models for FIM? And did the instruct model also get FIM finetuned tasks?
Thank you very much!
@pkuzqh commented on GitHub (Dec 7, 2023):
@SinanAkkoyun commented on GitHub (Dec 7, 2023):
Thanks a lot!
@pkuzqh commented on GitHub (Dec 7, 2023):
You are welcome!
@xidongyuandong commented on GitHub (Feb 29, 2024):
is not use FIM fintuned, how instrction model get the FIM ability?
@pkuzqh commented on GitHub (Feb 29, 2024):
you can directly use this code
import os
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from tqdm import tqdm
import torch.nn.functional as F
import json
#CUDA_VISIBLE_DEVICES=0
from transformers import LlamaConfig,LlamaForCausalLM,LlamaTokenizer
model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base/", trust_remote_code=True, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-6.7b-base/", trust_remote_code=True, padding_side='right')
prompt = """<|fim▁begin|>#!/usr/bin/env python3
<|fim▁hole|>
<|fim▁end|>"""
ids = tokenizer(prompt, return_tensors='pt').input_ids
out = model.generate(ids, max_new_tokens=100, do_sample=False, top_k=50, top_p=0.95, num_return_sequences=1)
print(tokenizer.decode(out[0][len(ids[0]):], skip_special_tokens=True))