

# NB GPT-J-6B NorPaca

This is a [NB GPT-J-6B](https://huggingface.co/NbAiLab/nb-gpt-j-6B) Norwegian Bokmål model fine-tuned on the [NorPaca](https://huggingface.co/datasets/MasterThesisCBS/NorPaca) dataset.

## Usage

```python
from transformers import AutoModelForCausalLM, AutoTokenizer, GenerationConfig, pipeline

base_model = "NbAiLab/nb-gpt-j-6B-norpaca"
tokenizer = AutoTokenizer.from_pretrained(base_model)
model = AutoModelForCausalLM.from_pretrained(base_model).cuda()
```

For generation, we can either use `pipeline()` or the model's `.generate()` method. Remember that the prompt needs a **Norwegian** template:

```python
# Generate responses
def generate(instruction, input=None):
    if input:
        prompt = f"""Nedenfor er en instruksjon som beskriver en oppgave, sammen med et input som gir ytterligere kontekst. Skriv et svar som fullfører forespørselen på riktig måte.

### Instruksjon:
{instruction}

### Input:
{input}

### Respons:"""
    else:
        prompt = f""""Nedenfor er en instruksjon som beskriver en oppgave. Skriv et svar som fullfører forespørselen på riktig måte.

### Instruksjon:
{instruction}

### Respons:"""
    inputs = tokenizer(prompt, return_tensors="pt")
    input_ids = inputs["input_ids"].cuda()
    generation_output = model.generate(
        input_ids=input_ids,
        generation_config=GenerationConfig(temperature=0.2, top_p=0.75, num_beams=4),
        return_dict_in_generate=True,
        output_scores=True,
        max_new_tokens=256
    )
    for seq in generation_output.sequences:
        output = tokenizer.decode(seq, skip_special_tokens=True)
        print(output.split("### Respons:")[-1].strip())

generate("Skriv en e-post der du ønsker velkommen til en ny medarbeider ved navn Svein.")
```


## Data

The dataset is a translation to Norwegian Bokmål of [alpaca_gpt4_data.json](https://github.com/Instruction-Tuning-with-GPT-4/GPT-4-LLM), a clean version of the [Alpaca dataset made at Stanford](https://huggingface.co/datasets/tatsu-lab/alpaca), but generated with GPT4.

**This dataset cannot be used to create models that compete in any way with OpenAI.**

## Finetuning

To fine-tune the NB GPT-J-6B model we used the code available on [NB's fork of `mesh-transformer-jax`](https://github.com/NbAiLab/mesh-transformer-jax/blob/master/prepare_dataset_alpaca.py), which provides code adapt an Alpaca dataset to finetune any GPT-J-6B model. We run finetuning for 3 epochs using sequence length of 2048 on a single TPUv3-8 for 3 hours on top of NB GPT-J-6B.


## References

- [Stanford Alpaca](https://github.com/tatsu-lab/stanford_alpaca)
- [Norwegian Alpaca](https://huggingface.co/datasets/NbAiLab/norwegian-alpaca)
- [ChatGPT](https://openai.com/blog/chatgpt)
- [Hugging Face](https://huggingface.co/)
 
## Hardware Requirements

For training we have used a Google Cloud TPUv3-8 VM. For eval, you can use a T4.
{"language": ["no", "nb"], "license": "openrail", "library_name": "transformers", "tags": ["alpaca"], "datasets": ["MasterThesisCBS/NorPaca"], "pipeline_tag": "conversational", "widget": [{"text": "Nedenfor er en instruksjon som beskriver en oppgave. Skriv et svar som fullf\u00f8rer foresp\u00f8rselen p\u00e5 riktig m\u00e5te.\n### Instruksjon: Skriv en e-post der du \u00f8nsker velkommen til en ny medarbeider ved navn Svein.\n### Respons:", "example_title": "E-mail"}, {"text": "Nedenfor er en instruksjon som beskriver en oppgave. Skriv et svar som fullf\u00f8rer foresp\u00f8rselen p\u00e5 riktig m\u00e5te.\n### Instruksjon: Fortell meg noe om alpakkaer.\n### Respons:", "example_title": "Alpacas"}, {"text": "Nedenfor er en instruksjon som beskriver en oppgave. Skriv et svar som fullf\u00f8rer foresp\u00f8rselen p\u00e5 riktig m\u00e5te.\n### Instruksjon: Kom med en kreativ unnskyldning for \u00e5 si at jeg ikke trenger \u00e5 g\u00e5 p\u00e5 festen.\n### Respons:", "example_title": "Excuse"}], "extra_gated_prompt": "You agree to not use the model to conduct experiments that cause harm to human subjects.", "extra_gated_fields": {"Company": "text", "Country": "text", "Intended Use": "text"}}
transformers pytorch gptj text-generation alpaca conversational no nb dataset:MasterThesisCBS/NorPaca license:openrail autotrain_compatible endpoints_compatible region:us
TAGS
#transformers #pytorch #gptj #text-generation #alpaca #conversational #no #nb #dataset-MasterThesisCBS/NorPaca #license-openrail #autotrain_compatible #endpoints_compatible #region-us 



# NB GPT-J-6B NorPaca

This is a NB GPT-J-6B Norwegian Bokmål model fine-tuned on the NorPaca dataset.

## Usage



For generation, we can either use 'pipeline()' or the model's '.generate()' method. Remember that the prompt needs a Norwegian template:




## Data

The dataset is a translation to Norwegian Bokmål of alpaca_gpt4_data.json, a clean version of the Alpaca dataset made at Stanford, but generated with GPT4.

This dataset cannot be used to create models that compete in any way with OpenAI.

## Finetuning

To fine-tune the NB GPT-J-6B model we used the code available on NB's fork of 'mesh-transformer-jax', which provides code adapt an Alpaca dataset to finetune any GPT-J-6B model. We run finetuning for 3 epochs using sequence length of 2048 on a single TPUv3-8 for 3 hours on top of NB GPT-J-6B.


## References

- Stanford Alpaca
- Norwegian Alpaca
- ChatGPT
- Hugging Face
 
## Hardware Requirements

For training we have used a Google Cloud TPUv3-8 VM. For eval, you can use a T4.
# NB GPT-J-6B NorPaca

This is a NB GPT-J-6B Norwegian Bokmål model fine-tuned on the NorPaca dataset. ## Usage



For generation, we can either use 'pipeline()' or the model's '.generate()' method. Remember that the prompt needs a Norwegian template: ## Data

The dataset is a translation to Norwegian Bokmål of alpaca_gpt4_data.json, a clean version of the Alpaca dataset made at Stanford, but generated with GPT4.

This dataset cannot be used to create models that compete in any way with OpenAI. ## Finetuning

To fine-tune the NB GPT-J-6B model we used the code available on NB's fork of 'mesh-transformer-jax', which provides code adapt an Alpaca dataset to finetune any GPT-J-6B model. We run finetuning for 3 epochs using sequence length of 2048 on a single TPUv3-8 for 3 hours on top of NB GPT-J-6B. ## References

- Stanford Alpaca
- Norwegian Alpaca
- ChatGPT
- Hugging Face ## Hardware Requirements

For training we have used a Google Cloud TPUv3-8 VM. For eval, you can use a T4.
TAGS
#transformers #pytorch #gptj #text-generation #alpaca #conversational #no #nb #dataset-MasterThesisCBS/NorPaca #license-openrail #autotrain_compatible #endpoints_compatible #region-us 
 # NB GPT-J-6B NorPaca

This is a NB GPT-J-6B Norwegian Bokmål model fine-tuned on the NorPaca dataset. ## Usage



For generation, we can either use 'pipeline()' or the model's '.generate()' method. Remember that the prompt needs a Norwegian template: ## Data

The dataset is a translation to Norwegian Bokmål of alpaca_gpt4_data.json, a clean version of the Alpaca dataset made at Stanford, but generated with GPT4.

This dataset cannot be used to create models that compete in any way with OpenAI. ## Finetuning

To fine-tune the NB GPT-J-6B model we used the code available on NB's fork of 'mesh-transformer-jax', which provides code adapt an Alpaca dataset to finetune any GPT-J-6B model. We run finetuning for 3 epochs using sequence length of 2048 on a single TPUv3-8 for 3 hours on top of NB GPT-J-6B. ## References

- Stanford Alpaca
- Norwegian Alpaca
- ChatGPT
- Hugging Face ## Hardware Requirements

For training we have used a Google Cloud TPUv3-8 VM. For eval, you can use a T4.
TAGS
#transformers #pytorch #gptj #text-generation #alpaca #conversational #no #nb #dataset-MasterThesisCBS/NorPaca #license-openrail #autotrain_compatible #endpoints_compatible #region-us 
# NB GPT-J-6B NorPaca

This is a NB GPT-J-6B Norwegian Bokmål model fine-tuned on the NorPaca dataset.## Usage



For generation, we can either use 'pipeline()' or the model's '.generate()' method. Remember that the prompt needs a Norwegian template:## Data

The dataset is a translation to Norwegian Bokmål of alpaca_gpt4_data.json, a clean version of the Alpaca dataset made at Stanford, but generated with GPT4.

This dataset cannot be used to create models that compete in any way with OpenAI.## Finetuning

To fine-tune the NB GPT-J-6B model we used the code available on NB's fork of 'mesh-transformer-jax', which provides code adapt an Alpaca dataset to finetune any GPT-J-6B model. We run finetuning for 3 epochs using sequence length of 2048 on a single TPUv3-8 for 3 hours on top of NB GPT-J-6B.## References

- Stanford Alpaca
- Norwegian Alpaca
- ChatGPT
- Hugging Face## Hardware Requirements

For training we have used a Google Cloud TPUv3-8 VM. For eval, you can use a T4.