transformers pytorch gpt_bigcode text-generation en dataset:guanaco license:apache-2.0 autotrain_compatible text-generation-inference endpoints_compatible region:us
---
datasets:
- guanaco
language:
- en
license:
- apache-2.0
model_hub_library:
- transformers
---

## WizardGuanaco-V1.0 Model Card
The WizardCoder-Guanaco-15B-V1.0 is a language model that combines the strengths of the [WizardCoder](https://huggingface.co/WizardLM/WizardCoder-15B-V1.0) base model and the [openassistant-guanaco](https://huggingface.co/datasets/timdettmers/openassistant-guanaco) dataset for finetuning. The openassistant-guanaco dataset was further trimmed to within 2 standard deviations of token size for input and output pairs and all non-english data has been removed to reduce training size requirements.

# Model Description
This model is built on top of the WizardCoder base model, a large language model known for its impressive capabilities in code related instruction. The WizardCoder base model was further finetuned using QLORA on the openassistant-guanaco dataset to enhance its generative abilities.

However, to ensure more targeted learning and data processing, the dataset was trimmed to within 2 standard deviations of token size for question sets. This process enhances the model's ability to generate more precise and relevant answers, eliminating outliers that could potentially distort the responses. In addition, to focus on English language proficiency, all non-English data has been removed from the Guanaco dataset.

# Intended Use
This model is designed to be used for a wide array of text generation tasks that require understanding and generating English text. The model is expected to perform well in tasks such as answering questions, writing essays, summarizing text, translation, and more. However, given the specific data processing and finetuning done, it might be particularly effective for tasks related to English language question-answering systems.

# Limitations
Despite the powerful capabilities of this model, users should be aware of its limitations. The model's knowledge is up to date only until the time it was trained, and it doesn't know about events in the world after that. It can sometimes produce incorrect or nonsensical responses, as it doesn't understand the text in the same way humans do. It should be used as a tool to assist in generating text and not as a sole source of truth.

# How to use
Here is an example of how to use this model:

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import time
import torch

class Chatbot:
    def __init__(self, model_name):
        self.tokenizer = AutoTokenizer.from_pretrained(model_name, padding_side='left')
        self.model = AutoModelForCausalLM.from_pretrained(model_name, load_in_4bit=True, torch_dtype=torch.bfloat16)
        if self.tokenizer.pad_token_id is None:
            self.tokenizer.pad_token_id = self.tokenizer.eos_token_id

    def get_response(self, prompt):
        inputs = self.tokenizer.encode_plus(prompt, return_tensors="pt", padding='max_length', max_length=100)
        if next(self.model.parameters()).is_cuda:
            inputs = {name: tensor.to('cuda') for name, tensor in inputs.items()}
        start_time = time.time()
        tokens = self.model.generate(input_ids=inputs['input_ids'], 
                                    attention_mask=inputs['attention_mask'],
                                    pad_token_id=self.tokenizer.pad_token_id,
                                    max_new_tokens=400)
        end_time = time.time()
        output_tokens = tokens[0][inputs['input_ids'].shape[-1]:]
        output = self.tokenizer.decode(output_tokens, skip_special_tokens=True)
        time_taken = end_time - start_time
        return output, time_taken

def main():
    chatbot = Chatbot("LoupGarou/WizardCoder-Guanaco-15B-V1.0")
    while True:
        user_input = input("Enter your prompt: ")
        if user_input.lower() == 'quit':
            break
        output, time_taken = chatbot.get_response(user_input)
        print("\033[33m" + output + "\033[0m")
        print("Time taken to process: ", time_taken, "seconds")
    print("Exited the program.")

if __name__ == "__main__":
    main()

```

# Training Procedure
The base WizardCoder model was finetuned on the openassistant-guanaco dataset using QLORA, which was trimmed to within 2 standard deviations of token size for question sets and randomized. All non-English data was also removed from this finetuning dataset.

## Acknowledgements
This model, WizardCoder-Guanaco-15B-V1.0, is simply building on the efforts of two great teams to evaluate the performance of a combined model with the strengths of the [WizardCoder base model](https://huggingface.co/WizardLM/WizardCoder-15B-V1.0) and the [openassistant-guanaco dataset](https://huggingface.co/datasets/timdettmers/openassistant-guanaco). 

A sincere appreciation goes out to the developers and the community involved in the creation and refinement of these models. Their commitment to providing open source tools and datasets have been instrumental in making this project a reality. 

Moreover, a special note of thanks to the [Hugging Face](https://huggingface.co/) team, whose transformative library has not only streamlined the process of model creation and adaptation, but also democratized the access to state-of-the-art machine learning technologies. Their impact on the development of this project cannot be overstated.
