Rago v1 1B model is a retrieval-augmented generation-optimized (RAGO) model, which enhances large language models by integrating an external authoritative knowledge base (context) for generating responses. This integration significantly improves the model's ability to produce relevant, accurate, and context-specific output across specialized domains or internal data without necessitating retraining. It addresses key challenges of large language models (LLMs), such as unpredictability, reliance on potentially outdated data, and the propagation of incorrect information, thereby improving user trust in AI applications. Rago v1 1B, specifically, is an advancement built upon the
Falcon-RW-1B model, optimized for retrieval-augmented generation, making it particularly effective in contextually aware response generation.
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import transformers
3import torch
4
5model = "neural-bridge/Rago-v1-1b"
6
7tokenizer = AutoTokenizer.from_pretrained(model)
8pipeline = transformers.pipeline(
9 "text-generation",
10 model=model,
11 tokenizer=tokenizer,
12 torch_dtype=torch.bfloat16,
13 trust_remote_code=True,
14 device_map="auto",
15)
16
17def create_prompt(context, question):
18 return f"""##CONTEXT## {context} ##QUESTION## {question} ##ANSWER##"""
19
20sequences = pipeline(
21 create_prompt(
22 context="Neural Bridge AI is a software company developing artificial intelligence (AI) solutions. It is founded in New York in the USA.",
23 question="What solutions does Neural Bridge AI develop for its clients?"
24 ),
25 max_length=200,
26 do_sample=True,
27 top_k=10,
28 num_return_sequences=1,
29 eos_token_id=tokenizer.eos_token_id,
30)
31
32def print_result(generated_text):
33 result_start = "##ANSWER##"
34 answer_start = generated_text.find(result_start)
35 print(generated_text[answer_start + len(result_start) :].strip())
36
37for seq in sequences:
38 print_result(seq["generated_text"])
Rago v1 1B has been trained using the
Neural Bridge's RAG Full 20000 dataset, which comprises a blend of
RefinedWeb,
gms8k, and
RAG Hallucination Dataset 1000.
In terms of training specifics, Rago v1 1B is built upon
Falcon-RW-1B employing
LoRA to enhance the model's capability to deliver relevant, precise, and context-specific output across specialized domains or internal datasets. This approach aims to tackle significant challenges faced by LLMs, such as unpredictability, reliance on potentially outdated information, and the spread of incorrect data. The architecture of Rago v1 1B mirrors that of
Falcon-RW-1B, augmented with
LoRA adapters. The model is trained with 4-bit quantization on a single NVIDIA A100 GPU for approximately one hour, utilizing a learning rate of
2e-5 with cosine scheduler, alongside the following LoRA parameters:
Rago v1 1B benefits from a custom data collator designed to boost model performance significantly. Employing a masked language modeling (MLM) strategy, the model is fine-tuned to generate more accurate responses by exclusively masking the answer portion of the training data. This custom data collator has led to noticeable improvements in the model's factuality performance.
This public extract is made available under
Apache license 2.0. Users should also abide to the
Falcon-RW-1B ToU.