Giter VIP home page Giter VIP logo

magicoder's Introduction

๐ŸŽฉ Magicoder: Source Code Is All You Need

๐ŸŽฉย Models | ๐Ÿ“šย Dataset | ๐Ÿš€ย Quick Start | ๐Ÿ‘€ย Demo | ๐Ÿ“ย Citation | ๐Ÿ™ย Acknowledgements

Important

We are keeping improving the documents and adding more implementation details. Please stay tuned!

About

  • ๐ŸŽฉMagicoder is a model family empowered by ๐Ÿช„OSS-Instruct, a novel approach to enlightening LLMs with open-source code snippets for generating low-bias and high-quality instruction data for code.
  • ๐Ÿช„OSS-Instruct mitigates the inherent bias of the LLM-synthesized instruction data by empowering them with a wealth of open-source references to produce more diverse, realistic, and controllable data.
  • Magicoder-S-DS-6.7B outperforms gpt-3.5-turbo-1106 and Gemini Ultra on HumanEval (76.8 vs. [72.6 and 74.4])!

Overview of OSS-Instruct Overview of Result

๐ŸŽฉ Models

Model Checkpoint Size HumanEval (+) MBPP (+) Demo License
Magicoder-CL-7B ๐Ÿค— HF Link 7B 60.4 (55.5) 64.2 (52.6) -- Llama2
Magicoder-S-CL-7B ๐Ÿค— HF Link 7B 70.7 (66.5) 68.4 (56.6) -- Llama2
Magicoder-DS-6.7B ๐Ÿค— HF Link 6.7B 66.5 (60.4) 75.4 (61.9) -- DeepSeek
Magicoder-S-DS-6.7B ๐Ÿค— HF Link 6.7B 76.8 (70.7) 75.7 (64.4) Demo* DeepSeek

*Demo link will expire on 12/8/2023.

๐Ÿ“š Dataset

๐Ÿš€ Quick Start

from transformers import pipeline
import torch

MAGICODER_PROMPT = """You are an exceptionally intelligent coding assistant that consistently delivers accurate and reliable responses to user instructions.

@@ Instruction
{instruction}

@@ Response
"""

instruction = "Implement a high-level API for a TODO list application. The API takes as input an operation request and updates the TODO list in place. If the request is invalid, raise an exception."

prompt = MAGICODER_PROMPT.format(instruction=instruction)
generator = pipeline(
    model="ise-uiuc/Magicoder-S-DS-6.7B",
    task="text-generation",
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
result = generator(prompt, max_length=2048, num_return_sequences=1, temperature=0.0)
print(result[0]["generated_text"])

This code snippet will generate the following output:

Here is a simple Python implementation of a TODO list API:

```python
class TodoList:
    def __init__(self):
        self.todo_list = []

    def add_task(self, task):
        if not isinstance(task, str):
            raise ValueError("Task must be a string")
        self.todo_list.append(task)

    def remove_task(self, task):
        if task not in self.todo_list:
            raise ValueError("Task not found in the list")
        self.todo_list.remove(task)

    def get_tasks(self):
        return self.todo_list

    def update_task(self, old_task, new_task):
        if old_task not in self.todo_list:
            raise ValueError("Old task not found in the list")
        if not isinstance(new_task, str):
            raise ValueError("New task must be a string")
        index = self.todo_list.index(old_task)
        self.todo_list[index] = new_task

    def clear_list(self):
        self.todo_list = []
```

This API allows you to add tasks, remove tasks, get all tasks, update tasks, and clear the list. It also raises exceptions for invalid operations.

You can use this API like this:

```python
todo = TodoList()
todo.add_task("Buy groceries")
todo.add_task("Finish project")
print(todo.get_tasks())  # Output: ['Buy groceries', 'Finish project']
todo.update_task("Buy groceries", "Buy fruits")
print(todo.get_tasks())  # Output: ['Buy fruits', 'Finish project']
todo.remove_task("Finish project")
print(todo.get_tasks())  # Output: ['Buy fruits']
todo.clear_list()
print(todo.get_tasks())  # Output: []
```

๐Ÿ‘€ Demo

We follow WizardCoder and provide the script to build a local demo server with gradio. Refer to /demo for more information.

๐Ÿ“ Citation

@misc{magicoder,
    title={Magicoder: Source Code Is All You Need}, 
    author={Yuxiang Wei and Zhe Wang and Jiawei Liu and Yifeng Ding and Lingming Zhang},
    year={2023},
    eprint={2312.02120},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}

๐Ÿ™ Acknowledgements

โš ๏ธ Important Note

  • Bias, Risks, and Limitations: Magicoders may sometimes make errors, produce misleading contents, or struggle to manage tasks that are not related to coding.

  • Usage: Magicoder models are trained on the synthetic data generated by OpenAI models. Please pay attention to OpenAI's terms of use when using the models and the datasets. Magicoders will not compete with any OpenAI's commercial product.

โญ๏ธ Star History

Star History Chart

magicoder's People

Contributors

universefly avatar natedingyifeng avatar zhewang2001 avatar ganler avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.