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
---

## Starcoderplus-Guanaco-GPT4-15B-V1.0 Model Card
Starcoderplus-Guanaco-GPT4-15B-V1.0 is a language model that combines the strengths of the [Starcoderplus](https://huggingface.co/bigcode/starcoderplus) base model, an expansion of the orginal [openassistant-guanaco](https://huggingface.co/datasets/timdettmers/openassistant-guanaco) dataset re-imagined using 100% GPT-4 answers, and additional data on abstract algebra and physics for finetuning. The original openassistant-guanaco dataset questions were trimmed to within 2 standard deviations of token size for input and output pairs and all non-english data was been removed to reduce training size requirements.

# Model Description
This model is built on top of the Starcoderplus base model, a large language model which is a fine-tuned version of [StarCoderBase](https://huggingface.co/bigcode/starcoderbase). The Starcoderplus base model was further finetuned using QLORA on the revised openassistant-guanaco dataset questions that were 100% re-imagined using GPT-4.

# 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/Starcoderplus-Guanaco-GPT4-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 Starcoderplus model was finetuned on the modified openassistant-guanaco dataset 100% re-imagined with GPT4 answers using QLORA. All non-English data was also removed from this finetuning dataset to reduce trainign size and time.

## Acknowledgements
This model, Starcoderplus-Guanaco-GPT4-15B-V1.0, builds upon the strengths of the [Starcoderplus](https://huggingface.co/bigcode/starcoderplus) 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.
