From d109946d967c17f1012fe09c5d59e7ce2a2cac9e Mon Sep 17 00:00:00 2001 From: Lingma Date: Wed, 30 Oct 2024 12:22:05 +0000 Subject: [PATCH] Update README.md --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index e797749..c7ad4af 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,47 @@ Lingma SWE-GPT has demonstrated impressive performance in software engineering t - Outperforms other open-source models of similar scale in software engineering-specific tasks. ## How to use + +### Run on SWE-bench Refer to https://github.com/LingmaTongyi/Lingma-SWE-GPT +### Quick Start +``` +from modelscope import AutoModelForCausalLM, AutoTokenizer + +model_name = "Lingma/Lingma-SWE-GPT-7B" + +model = AutoModelForCausalLM.from_pretrained( + model_name, + torch_dtype="auto", + device_map="auto" +) +tokenizer = AutoTokenizer.from_pretrained(model_name) + +prompt = "Give me a short introduction to large language model." +messages = [ + {"role": "system", "content": "You are Lingma, created by Tongyi Lingma team. You are a helpful assistant."}, + {"role": "user", "content": prompt} +] +text = tokenizer.apply_chat_template( + messages, + tokenize=False, + add_generation_prompt=True +) +model_inputs = tokenizer([text], return_tensors="pt").to(model.device) + +generated_ids = model.generate( + **model_inputs, + max_new_tokens=512 +) +generated_ids = [ + output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids) +] + +response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0] +print(response) +``` + ## TODO Currently only Python is supported. In future updates, we will provide more support for Java, JS/TS and other languages.