Downloads · 30 days
0
shijunju/gemma_7b_finRisk_r6_3VersionQ
gemma_7b_finRisk_r6_3VersionQ is a machine learning model from shijunju. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
Downloads · 30 days
0
Access
Public
Updated Nov 18, 2024
Repo size
66.6 MB
Likes
0
Public
Click a slice to open those files.
.h566.6 MB · 100%
From the Hugging Face model README
The repository includes only a LoRA adapter trained with keras-nlp on a TPU. To use the fine-tuned model, load Gemma-7b and apply load_lora_weights before generating output (see instructions below).
This model is fine-tuned using the LoRA (Low-Rank Adaptation) approach, specifically designed for question answering in the domain of financial risk compliance.
The Gemma-7b-en model is fine-tuned using documents from fincen.gov.
It is capable of answering questions about documents published on fincen.gov, including Alerts, Advisories, and Financial Trend Analysis reports since 2020.
shijunju/fincen_all_questions_5versions
Use the code below to get started with the model. (Require TPU or large GPU!)
# https://www.kaggle.com/code/nilaychauhan/keras-gemma-distributed-finetuning-and-inference
import tensorflow_text as text
model_parallel = keras.distribution.ModelParallel(
device_mesh=device_mesh,
layout_map=layout_map,
batch_dim_name="batch"
)
keras.distribution.set_distribution(model_parallel)
gemma_lm = keras_nlp.models.GemmaCausalLM.from_preset("gemma_7b_en")
gemma_lm.backbone.enable_lora(rank=6)
gemma_lm.backbone.load_lora_weights(MODEL_LORA_WT_PATH) # the folder and file name you save the downloaded adaptor from this repository
def generate_response(prompt, max_length=256):
outputs = gemma_lm.generate(prompt,
max_length=max_length
)
print(outputs)
inference_template = """<start_of_turn>user\nQuestion: {question}\n<end_of_turn>\n\n<start_of_turn>model\n"""
prompt = inference_template.format(
question="Identify the specific fraudulent scheme highlighted in the FinCEN alert related to requests for convertible virtual currency payments.",
response=""
)
print(generate_response(prompt))
If you encounter any errors, please refer to https://www.kaggle.com/code/nilaychauhan/keras-gemma-distributed-finetuning-and-inference for how to load the model into TPU properly.