Edit model card

LocalCoder-v0

A tiny (1.1B) parameter SLM for programming based on TinyLlama. It shows promising early results but has not been extensively tested.

The model was trained using supervised fine tuning (SFT) for 1 epoch on a large dataset of conversational code generation. While the model prioritizes code generation, it also performs decently at general conversational tasks and multi-round conversations. The model has the ability to correct code it has generated based on feedback given by the user, and can follow system prompts well.

The model can generate code in multiple programming languages but specializes in Python. This model currently only works with English.

This is an early open research preview. The model is still in an early stage. If you enjoy this model, please let me know - I'm thinking about training this model on more epochs or training a larger model.

Notes

Despite this being a decent model for its size, it tends to tell you what the output of the code would be (such as "When running this code, you will get ..."). This can be problematic as the model will hallucinate on the expected result. You can avoid this by explicitly telling it not to tell you what the result of the code it generates will be in the system prompt.

Additionally, because of its size, it isn't an amazing model. I'm hoping to train a 7B model in the future, since quantizing seems better than SLMs (at least at this stage).

Usage

This model uses the ChatML conversation format:

<|im_start|>system
You are a helpful coding assistant who knows a variety of languages.<|im_end|>
<|im_start|>user
How can I calculate the first 10 digits fo the Fibonacci sequence using Python?<|im_end|>
<|im_start|>assistant

You may load the model using Hugging Face Transformers after you have logged in to Hugging Face:

from transformers import pipeline
pipe = pipeline('text-generation', model='mrfakename/localcoder-0')
template = pipe.tokenizer.apply_chat_template([
    {
        'role': 'system',
        'content': 'You are a helpful coding assistant who knows a variety of languages.'
    },
    {
        'role': 'user',
        'content': 'Hello, how are you?'
    }
], tokenize=False, add_generation_prompt=True)
print(pipe(template)[0]['generated_text'])
Interactive chatbot example
from transformers import pipeline
import torch
device = 'cuda' if torch.cuda.is_available() else 'cpu'
pipe = pipeline('text-generation', model='mrfakename/localcoder-0', device=device)
messages = [
    {
        'role': 'system',
        'content': 'You are a helpful coding assistant who knows a variety of languages.'
    }
]
while True:
    user_input = input('You: ')
    messages.append({
        'role': 'user',
        'content': user_input
    })
    template = pipe.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
    result = pipe(template, return_full_text=False, temperature=0.6)[0]['generated_text'].replace('<|im_end|>', '').strip()
    print('Bot: ' + result)
    messages.append({
        'role': 'assistant',
        'content': result
    })

Examples

Hello, how are you doing today?

Hello! I'm doing great! How can I help you today?

How should I calculate the Fibonacci sequence using the Python programming language?

The Fibonacci sequence is a series of numbers in which each number is the sum of the two preceding ones, usually starting with 0 and 1. Here is a simple Python program that calculates the Fibonacci sequence:

def fibonacci(n):
    if n <= 1:
        return n
    else:
        a, b = 0, 1
        for _ in range(2, n + 1):
            a, b = b, a + b
        return b

n = 10
print(fibonacci(n))

In this program, fibonacci(n) calculates the nth Fibonacci number. The function fibonacci(n) checks if n is less than or equal to 1, in which case it returns n. Otherwise, it initializes a and b to 0 and 1 respectively, and then iterates from 2 to n + 1 (inclusive) to calculate the Fibonacci number at each step.

The output of this program will be the 10th Fibonacci number, which is 55.

Write me an essay about AI.

Title: AI: The Future of Our World

Introduction: Artificial Intelligence (AI) is a rapidly evolving field that has the potential to revolutionize our world in numerous ways. This essay will explore the various aspects of AI, its impact on our daily lives, and its potential for the future.

  1. AI Basics: Artificial Intelligence is a complex field that involves the development of intelligent systems capable of performing tasks that typically require human intelligence. AI systems are designed to learn from data and make decisions based on the information they receive. This process is known as machine learning, and it is the foundation of AI.

  2. AI Applications: AI has numerous applications in various fields. For example, AI is used in healthcare to diagnose diseases, in finance to detect fraud, and in transportation to optimize routes and schedules. In the realm of entertainment, AI is used to create and manage virtual reality experiences.

  3. Ethical Considerations: While AI has many benefits, it also raises ethical concerns. For instance, AI systems can be trained to discriminate against certain groups, leading to issues such as bias and discrimination. Additionally, AI systems can be used to manipulate public opinion, which raises concerns about transparency and accountability.

  4. AI Ethics and Governance: To address these ethical concerns, governments and organizations are working on developing AI ethics guidelines and regulations. These guidelines aim to ensure that AI systems are used responsibly and in a way that benefits society as a whole.

  5. AI and Jobs: AI has the potential to displace certain jobs in the future. For example, AI systems can be used to automate tasks that require human intelligence, such as data entry or customer service. However, this could also lead to job losses in certain sectors.

  6. AI and Privacy: AI systems can be used to track individuals' movements and behavior, which raises concerns about privacy. For instance, AI systems can be used to monitor people's online activity, which could lead to concerns about privacy and data security.

  7. AI and Security: AI systems can be used to detect and prevent cyber attacks, which is crucial in today's digital age. However, AI systems can also be used to infiltrate systems and steal sensitive information. Therefore, it is essential to develop robust security measures for AI systems.

  8. AI and Ethics: AI ethics is a growing field that focuses on the responsible use of AI systems. This includes issues such as transparency, accountability, and fairness. As AI systems become more sophisticated, it is crucial to develop ethical guidelines and regulations to ensure that AI systems are used responsibly and in a way that benefits society as a whole.

Conclusion: In conclusion, AI is a powerful and complex field that has the potential to revolutionize our world. While AI has many benefits, it also raises ethical concerns. To address these concerns, governments and organizations are working on developing AI ethics guidelines and regulations. AI systems can be used to automate tasks, but this could also lead to job losses in certain sectors. Additionally, AI systems can be used to track individuals' movements and behavior, which raises concerns about privacy and data security. However, AI systems can also be used to detect and prevent cyber attacks, which is crucial in today's digital age. As AI systems become more sophisticated, it is essential to develop ethical guidelines and regulations to ensure that AI systems are used responsibly and in a way that benefits society as a whole.

Risks

This model has not been extensively tested and may generate incorrect or inaccurate code. Always check before using generated code.

This model has not been "alignment-tuned" and does not have any safety or guardrail mechanisms. You are responsible for your usage of the model.

License

This model is open-access, not open sourced. Unfortunately, due to several factors (including the training dataset), this model may not be used commercially. You may run it locally, and the author(s) place no restriction on the outputs of the model. However, you are responsible for your usage of the model. This model may not be used to generate illegal or harmful content (including but not limited to malware, viruses, etc).

Downloads last month
8

Collection including mrfakename/localcoder-0