QwenLM / CodeQwen1.5

CodeQwen1.5 is the code version of Qwen, the large language model series developed by Qwen team, Alibaba Cloud.
384 stars 22 forks source link

CodeQwen1.5模型支持跨文件级别的infilling续写吗? #24

Closed Lanyu123 closed 2 months ago

Lanyu123 commented 2 months ago

你好,我在尝试用CodeQwen1.5模型做repository level级别的infilling代码续写,我应该怎样组建prompt的格式呢?模型支持repository level + infilling的这种续写方式吗?

huybery commented 2 months ago

https://github.com/QwenLM/CodeQwen1.5?tab=readme-ov-file#3-repository-level-code-completion

Lanyu123 commented 2 months ago

你好,可能我的问题没有描述清楚。你链接给的是对跨文件级别(repository level)的代码文件的续写,例子中的当前续写文件只有上半段,没有下半段,不是infilling的续写方式。我寻求的是在repository level级别的文件中,对当前文件做infilling代码续写,既要考虑跨文件内容,也要考虑当前文件的上下文,即repository level+infilling的代码续写方式,这种要怎么组建prompt呢?文档里没有给出例子,我尝试用以下的prompt构建方式: `input_text = """library-system

library.py class Book: def __init__(self, title, author, isbn, copies): self.title = title self.author = author self.isbn = isbn self.copies = copies def __str__(self): return f"Title: {self.title}, Author: {self.author}, ISBN: {self.isbn}, Copies: {self.copies}" class Library: def __init__(self): self.books = [] def add_book(self, title, author, isbn, copies): book = Book(title, author, isbn, copies) self.books.append(book) def find_book(self, isbn): for book in self.books: if book.isbn == isbn: return book return None def list_books(self): return self.books student.py class Student: def __init__(self, name, id): self.name = name self.id = id self.borrowed_books = [] def borrow_book(self, book, library): if book and book.copies > 0: self.borrowed_books.append(book) book.copies -= 1 return True return False def return_book(self, book, library): if book in self.borrowed_books: self.borrowed_books.remove(book) book.copies += 1 return True return False main.py from library import Library from student import Student def main(): # Set up the library with some books library = Library() library.add_book("The Great Gatsby", "F. Scott Fitzgerald", "1234567890", 3) library.add_book("To Kill a Mockingbird", "Harper Lee", "1234567891", 2) # Set up a student student = Student("Alice", "S1") # Student borrows a book if student.borrow_book(book, library): print(f"{student.name} borrowed {book.title}") else: print(f"{student.name} could not borrow {book.title}") # Student returns a book if student.return_book(book, library): print(f"{student.name} returned {book.title}") else: print(f"{student.name} could not return {book.title}") # List all books in the library print("All books in the library:") for book in library.list_books(): print(book) if __name__ == "__main__": main() """ ` 但是似乎模型并不奏效,请问模型支持这种repository level+infilling的续写方式吗?我该怎么构建prompt呢?望请回复,十分感谢!