PS: See https://github.com/unit-mesh/unit-eval for fine-tuning related to code completion and document generation:
Statement: The data sets and LoRA binary provided by this project are all created by OpenAI or published online. We only provide tutorials related to model training, and all consequences caused by the actual training content of the user is the responsibility of the user himself.
For engineers, we can clearly see the impact of large language models such as ChatGPT, and thus we have carried out research on the improvement of R&D efficiency of AI - trained several methods used to study R&D efficiency of LLaMA LoRA and ChatGLM LoRA.
This project is our research result, including some video introductions, trained models, training code, training data, and some records during the training process.
See Release for training LoRA.
Training Notebook:
LLaMA Series Online Video:
ChatGLM Series Online Video:
Table of contents:
Related data conversion is available at: https://github.com/unit-mesh/minions-data-prepare
PS: If you need better code generation, it is recommended to use: https://huggingface.co/Salesforce/codegen-16B-mono
We are using the cloud GPU provided by OpenBayes: https://openbayes.com/console/signup?r=phodal_uVxU
The OpenBayes model can be used:
Roadmap:
Thanks: AIOS Club for OpenAI Key, Thanks OpenBayes for Cloud GPU
AI’s perceptual efficiency improvement depends on the standardization of R&D efficiency and splitting each step as carefully as possible.
In order to make the training results more accurate, we split the steps of software development in detail to ensure that each step produces accurate results, thereby driving accurate results. Here is an example of a small part of the detailed process we had in our early split:
We need to split it into each step as small as possible, feeding data in each refined step to make the AI produce the greatest repeater effect.
Todos
We use very simple instructs and provide them as much as possible for easy integration into the tool. as follows:
Corresponding functions introduction:
Judging from the test results, as the amount of data increases, for example, 20,000 code use cases are more "smart" than 10,000 code use cases.
Basic ideas:
As shown below:

Design a User Story Mapping for ${domain} application based on your understanding. Here are the requirements:
1 . Your user story map should include only user tasks to demonstrate how users will interact with the application.
2 . Our user story map should be based on your understanding of the ${domain} application and its users, and should be
designed to address their needs and pain points.
3 . You may use any tools or formats you choose to create your user story map, but it should be easily shareable and
understandable by stakeholders.
4 . Your expression should be more concise and clear.
5 . Your return should be like as follows:
###
User Tasks:
1 . ...
###Sample output:
User Tasks:
1. Browse and search for animations and comics
2. View details of animations and comics
3. Create an account
4. Log in to the account
5. Add animations and comics to favorites
6. Download animations and comics
7. Share animations and comics with friends
8. Rate and review animations and comics
9. Create and upload animations and comics
10. Participate in online forums and discussions
为下面的需求编写用户故事:${domain} 应用的 ${story_name} 功能。 要求如下:
1 . 必须要考虑尽可能考虑各种异常场景,添加更多的 AC。
2 . 你的返回模板如下所示:
###
用户故事:可以选择宝贝出行服务
作为 莉莉妈
我想 在滴滴打车的手机客户端里选择宝贝出行服务
以便于 我能够带宝宝打车出行的时候打到有儿童座椅的车
AC 1: 莉莉妈可以选择宝贝出行服务
假设 xxx
当 xxx
于是 xxx
###Sample output:
用户故事:可以创建和上传动画和漫画
作为一个 Animation and Comics 应用的用户
我想要创建和上传动画和漫画
以便于我可以分享我的作品给其他用户
AC 1: 用户可以创建和上传动画和漫画
假设 用户已经登录到 Animation and Comics 应用
当 用户点击创建和上传动画和漫画按钮
于是 用户可以创建和上传动画和漫画
Basic ideas:

src/main . PostService(PostRepository, UserRepository, ImageService)
- fields: postRepository:PostRepository, userRepository:UserRepository, userPosts:Set<Post>, imageService:ImageService
- methods: findAll(): List<Post>, addNewPost(Post): Post, saveImageToPost(String, MultipartFile, Post): int
Expected JSON format:
Example:
{"instruction":"Implement the method action","input":"com.thoughtworks.go.config.rules.AbstractDirective(DirectiveType, DirectiveType, String, String, String)n- fields: action:String, type:String, resource:String, configErrors:ConfigErrors, directiveType:DirectiveTypen- methods: validate(ValidationContext): void, isInvalid(String, List<String>): boolean, matchesAction(String): boolean, matchesType(Class<? extends Validatable>): boolean, matchesResource(String): boolean, errors(): ConfigErrors, addError(String, String): void, equals(Object): boolean, action(): String, type(): String, resource(): String, hashCode(): int, hasErrors(): boolean, getDirectiveType(): DirectiveType","output":"public abstract class AbstractDirective implements Directive {nn @ConfigAttribute(value = "action", optional = false)n protected String action;nn @ConfigAttribute(value = "type", optional = false)n protected String type;nn @ConfigValuen private String resource;nn private final ConfigErrors configErrors = new ConfigErrors();nn private DirectiveType directiveType;nn public AbstractDirective(DirectiveType allow) {n this.directiveType = allow;n }nn public AbstractDirective(DirectiveType allow, String action, String type, String resource) {n this.directiveType = allow;n this.action = action;n this.type = type;n this.resource = resource;n }nn @Overriden public String action() {n return this.action;n }n}n"}
Format specification:
包名.类名(类的构造类型)
- fields:成员变量集合(变量名:类型)
- methods:方法抽象集合(方法名(参数类型): 输出类型)
result:
com.thoughtworks.go.config.rules.AbstractDirective(DirectiveType, DirectiveType, String, String, String)
- fields: action:String, type:String, resource:String, configErrors:ConfigErrors, directiveType:DirectiveType
- methods: validate(ValidationContext): void, isInvalid(String, List<String>): boolean, matchesAction(String): boolean, matchesType(Class<? extends Validatable>): boolean, matchesResource(String): boolean, errors(): ConfigErrors, addError(String, String): void, equals(Object): boolean, action(): String, type(): String, resource(): String, hashCode(): int, hasErrors(): boolean, getDirectiveType(): DirectiveType
val javaProcessor = JavaProcessor (file.readText())
val shotClass = javaProcessor.toShortClass() ? : return @forEach
javaProcessor
.removePackage()
.removeAllImport()
.removeLicenseInfoBeforeImport()
javaProcessor.splitMethods().forEach { (key, value) ->
CodegenPrompt (
instruction = " Implement the method $key " ,
input = shotClass.toString(),
output = value
). let { prompt ->
val output = Json .encodeToString(prompt)
File ( " $targetPath${key} .json " ).writeText(output)
}
}Basic ideas

Grammatical analysis ideas:
src/main for each project. If the corresponding test file exists at the same time, it will be pulled into the dataset. org.unitmesh.processor.TestClass(String, Int)
- fields: field1:String, field2:Int
- methods: method1(String, Int): String, method2(): Int
class TestProcessorTest {
@ Test
void test1 () {
}
@ Test
void test2 () {
}
}Finally, the generated data is as follows:
{"classInfo": "com.thoughtworks.go.security.AESEncrypter(AESCipherProvider)n- fields: ENCODER:Base64.Encoder, DECODER: Base64.Decoder, cipherProvider:AESCipherProvider, ivProvider:IVProvidern- methods: createIVProviderInstance(): IVProvider, canDecrypt(String): boolean, encrypt(String): String, decrypt(String): String, createSecretKeySpec(): SecretKeySpec", "testMethod": "public class AESEncryptterTest {nn private AESEncryptter aesEncryptter;nn @Testn public void shouldGenerateEncryptedText() throws CryptoException {n String encrypt = aesEncryptter.encrypt("p@ssw0rd");n assertThat(encrypt).startsWith("AES");n assertThat(encrypt.split(":")).hasSize(3);n }n}n", "id": "task_0"}
For detailed code, see: test-to-code.py
The last generated propt example is as follows:
You are a programmer and implementation a method with TDD. Here are the requirements:
1 . According follows class information and tests code to write a method.
2 . Try you best to thinking corner case.
3 . You only return the code, no explain.
class information:
###
io.github.robwin.swagger.test.AbstractContractValidator()
- methods: findExpectedPaths(Swagger, SwaggerAssertionConfig): Map<String,Path>, getPathsIncludingBasePath(Swagger):
Map<String,Path>, getPathsWithPrefix(Swagger, String): Map<String,Path>, isBlankOrSlash(String): boolean
###
test code:
###
/ **
* Tests AbstractContractValidator.
* /
@ RunWith (Enclosed.class)
public class AbstractContractValidatorTest {
/ **
* Tests getPathsIncludingBasePath().
* /
public static class GetPathsIncludingBasePath {
@ Test
public void shouldReturnPathsPrefixedIfBasePathSet() {
// given
Swagger swagger = buildSwaggerFrom("/swagger.json");
// when
Map<String, Path> paths = new DummyValidator().getPathsIncludingBasePath(swagger);
// then
paths.entrySet().forEach(e -> assertThat(e.getKey(), startsWith(swagger.getBasePath())));
}
}
/ **
* Tests findExpectedPaths().
* /
public static class FindExpectedPaths {
}
private static class DummyValidator extends AbstractContractValidator {
}
}
###
Use existing Datasets, including:
However, these two code sets are not of high quality, but are basically available.
The format is as follows:
instruction:
我想查找特定月份(monthly_id)下在某个日期(date)之前的所有费用(expense),以方便了解特定月份内的开销情况。
input:
data class ExpenseEntity(....)
output:
@Query("SELECT * FROM expense WHERE monthly_id = :recurringExpenseId AND date < :beforeDate")
suspend fun getAllExpensesForRecurringExpenseBeforeDate(recurringExpenseId: Long, beforeDate: LocalDate): List<ExpenseEntity>
evaluate("text to kotlin repository with class", "我想查询指定年龄的用户(User)的博客数量。n ###data class User(var age: Int,
val blogId: Int) data class Post(val title: String)###", 0.1, 0.75, 40, 4, 512)
@Query("SELECT COUNT(*) FROM User WHERE age = :age")
abstract fun getBlogCount(age: Int): Long
Basic ideas:
instruction , and input output null.Example:
instruction: 介绍一下财通财通宝的基金管理人、基金托管人在履行各自职责的过程中,违反《基金法》?
(一)基金管理人、基金托管人在履行各自职责的过程中,违反《基金法》等法律法规的规定或者基金合同约定, 给基金财产或者基金份额持有人造成损害的,
应当分别对各自的行为依法承担赔偿责任;因共同行为给基金财产或者基金份额持有人造成损害的,应当承担连带赔偿责任,对 损失的赔偿,仅限于直接损失。
但是发生下列情况,当事人可以免责: 1.基金管理人及基金托管人按照中国证监会的规定或当时有效的法律法规的作为或不作为而造成的损失等;
2.基金管理人由于按照基金合同规定的投资原则而行使或不行使其投资权而造成的损失等; 3.不可抗力。
train:
Training time:
Related background:
Since, our goal is not to tune the model and generate a general model, but to train Lora for a specific purpose. Therefore, we did not join the data in Stanford Alpaca, so the time required is shorter. For example, the 8000+ test code only takes 1 hour, and the 3400+ user stories only take 25 minutes.
Training results (LoRA) are available at: https://github.com/unit-mesh/unit-minions/releases/tag/v0.0.1
print(evaluate("write test", """
public Set<String> listFilesUsingJavaIO(String dir) {
return Stream.of(new File(dir).listFiles())
.filter(file -> !file.isDirectory())
.map(File::getName)
.collect(Collectors.toSet());
}
""", 0.1, 0.75, 40, 4, 512))
## Output:
public class ListFilesUsingJavaIOTest {
@Test
public void shouldListFilesUsingJavaIO() {
Set<String> files = ListFilesUsingJavaIO.listFilesUsingJavaIO(new File("dir"));
assertThat(files, containsInAnyOrder("file1", "file2", "file3"));
}
}
Training results (LoRA) are available at: https://github.com/unit-mesh/unit-minions/releases/tag/v0.0.2
Notice:
--val_set_size 500--val_set_size 500--val_set_size 500Sample output :
print(evaluate("create Agile user story for following topic: ", "购买电影票", 0.1, 0.75, 40, 4, 512))
用户故事:可以购买电影票
作为一个电影票购买者
我想在购买电影票应用中购买电影票
以便于我可以购买电影票
AC 1: 电影票购买者可以在购买电影票应用中购买电影票
假设 电影票购买者已经登录购买电影票应用
当 电影票购买者点击“购买电影票”按钮
于是 电影票购买者可以在购买电影票应用中购买电影票
AC 2: 电影票购买者可以在购买电影票应用中查看购买记录
假设 电影票购买者已经登录购买电影票应用
当 电影票购买者点击“查看购买记录”按钮
于是 电影票购买者可以在购买电影票应用中查看购买记录
AC 3: 电影票购买者可以在购买电影票应用中查看购买记录
假设 电影票购买者已经登录购买电影票应用
当 电影票购买者点击“查看购买记录”按��
Training results (LoRA) are available at: https://github.com/unit-mesh/unit-minions/releases/tag/v0.0.3
Sample output :
print(evaluate("Implement the method rmFiles", "FileUtils:", 0.1, 0.75, 40, 4, 512))
public class FileUtils {
private FileUtils() {
}
public static void rmFiles(String path) {
File dir = new File(path);
File[] files = dir.listFiles();
if (files != null) {
for (File file : files) {
if (file.isFile()) {
file.delete();
} else if (file.isDirectory()) {
FileUtils.rmFiles(file.getAbsolutePath());
}
}
}
}
}
Conversion script: code/text-to-sql.py
Directly from: datasets/sql/sql-train.jsonl
Sample output :
evaluate("text to sql", "谁是最美丽的人", 0.1, 0.75, 40, 4, 512)
evaluate("text to sql", "小明今年几岁", 0.1, 0.75, 40, 4, 512)
evaluate("text to sql", "What hand guard system is used with a gas piston commando?", 0.1, 0.75, 40, 4, 512)
train:
Example 1:
evaluate("Instruction: 创建用户故事nInput: 电影网站: 查看订单详情 nAnswer:")
Instruction: 创建用户故事
Input: 电影网站: 查看订单详情
Answer:
用户故事:可以查看订单详情
作为一个电影网站的用户
我想查看订单详情
以便于我可以了解订单的详细信息,如订单号、订单状态、订单内容等。
AC 1: 用户可以查看订单详情
假设 用户已经登录
当 用户点击查看订单详情按钮
于是 用户可以查看订单详情,包括订单号、订单状态、订单内容等。
AC 2: 用户可以查看订单详情
假设 用户没有登录
当 用户点击查看订单详情按钮
于是 用户被要求先登录,然后才能查看订单详情,包括订单号、订单状态、订单内容等。
Example 2:
evaluate("Instruction: 创建用户故事nInput: 团购网站:用户注册nAnswer:")
Instruction: 创建用户故事
Input: 团购网站:用户注册
Answer:
团购网站的用户注册故事:
作为一个团购网站的用户
我想注册一个团购网站的用户账号
以便于我可以使用团购服务,如购买商品、服务等。
AC 1: 团购网站的用户注册账号
假设 用户输入了注册信息
当 用户提交注册信息
于是 用户可以成功注册一个团购网站的用户账号
AC 2: 团购网站的用户注册账号
假设 用户输入了错误的注册信息
当 用户提交注册信息
于是 用户可以被提示输入正确的注册信息,并重新提交注册信息