Run this model with HF Jobs

Run XiaofengAlg/Transport-llama3_1_8B_instruct on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs and TRL to fine-tune https://huggingface.co/XiaofengAlg/Transport-llama3_1_8B_instruct. Ask me which dataset to train on, then push the fine-tuned model to a new private model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/XiaofengAlg/Transport-llama3_1_8B_instruct on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Evaluate on a benchmark

Use HF Jobs to evaluate https://huggingface.co/XiaofengAlg/Transport-llama3_1_8B_instruct. Ask me which benchmark to run, then save the scores and the per-example results to a new private dataset repo. Run `hf jobs --help` first to learn the CLI.

Quantize for lower memory use

Use HF Jobs to create a 4-bit version of https://huggingface.co/XiaofengAlg/Transport-llama3_1_8B_instruct. Push it to a new private model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.

You need to agree to share your Hugging Face information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

You agree to not use the model to conduct experiments that cause harm to human subjects.

Log in or Sign Up to review the conditions and access this model content.

Transport Llama-3.1-8B-Instruct

Domain-adapted instruction model for transportation, fine-tuned from Meta-Llama-3.1-8B-Instruct on BAAI/IndustryInstruction_Transportation. Part of the Industry-Domain LLMs collection.

This model is finetuned on the model llama3.1-8b-instruct using the dataset BAAI/IndustryInstruction_Transportation dataset, the dataset details can jump to the repo: BAAI/IndustryInstruction

training params

The training framework is llama-factory, template=llama3

learning_rate=1e-5
lr_scheduler_type=cosine
max_length=2048
warmup_ratio=0.05
batch_size=64
epoch=10

select best ckpt by the evaluation loss

evaluation

Since I only found an instruction dataset DUOMO-Lab/Transgpt_sft_v2 in the field of traffic, in order to remove the influence of the base model, I used the data in llama3.1-8b-instruc for fine-tuning and compared and evaluated our model. The evaluation method is: use GPT4 on the validation set of each dataset to compare good, tie, and loss. The evaluation results are as follows

image/png

How to use

# !/usr/bin/env python
# -*- coding:utf-8 -*-
# ==================================================================
# [Author]       : xiaofeng
# [Descriptions] :
# ==================================================================

from transformers import AutoTokenizer, AutoModelForCausalLM
import transformers
import torch


llama3_jinja = """{% if messages[0]['role'] == 'system' %}
    {% set offset = 1 %}
{% else %}
    {% set offset = 0 %}
{% endif %}

{{ bos_token }}
{% for message in messages %}
    {% if (message['role'] == 'user') != (loop.index0 % 2 == offset) %}
        {{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}
    {% endif %}

    {{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] | trim + '<|eot_id|>' }}
{% endfor %}

{% if add_generation_prompt %}
    {{ '<|start_header_id|>' + 'assistant' + '<|end_header_id|>\n\n' }}
{% endif %}"""


dtype = torch.bfloat16

model_dir = "XiaofengAlg/Transport-llama3_1_8B_instruct"
model = AutoModelForCausalLM.from_pretrained(
    model_dir,
    device_map="cuda",
    torch_dtype=dtype,
)

tokenizer = AutoTokenizer.from_pretrained(model_dir)
tokenizer.chat_template = llama3_jinja # update template

message = [
    {"role": "system", "content": "You are a helpful assistant"},
    {"role": "user", "content": "私人交通工具的发展对经济有什么影响?"},
]
prompt = tokenizer.apply_chat_template(
    message, tokenize=False, add_generation_prompt=True
)
print(prompt)
inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
prompt_length = len(inputs[0])
print(f"prompt_length:{prompt_length}")

generating_args = {
    "do_sample": True,
    "temperature": 1.0,
    "top_p": 0.5,
    "top_k": 15,
    "max_new_tokens": 512,
}


generate_output = model.generate(input_ids=inputs.to(model.device), **generating_args)

response_ids = generate_output[:, prompt_length:]
response = tokenizer.batch_decode(
    response_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
)
print(response)
"""
私人交通工具的发展对经济有着深远的影响。首先,私人交通工具的发展可以促进汽车制造业的繁荣。随着私人交通工具的需求增加,汽车制造商将面临更大的市场需求,从而带动产业链的发展,创造就业机会,增加经济收入。其次,私人交通工具的发展也会带动相关
  业的发展,如燃料供应、维修服务和保险等。这些行业的发展将为经济增长做出贡献。此外,私人交通工具的发展还会促进城市交通的便利性,提高人们的生活质量,从而带动消费,刺激经济发展。然而,私人交通工具的发展也会带来一些负面影响,如交通拥堵和环境
  染等问题。因此,政府需要采取相应的政策措施来平衡经济发展和环境保护的需要。总的来说,私人交通工具的发展对经济有着重要的影响,需要综合考虑各种因素进行合理规划和管理。
"""

Citation

@misc{shi2024industryinstruction,
  title     = {IndustryInstruction},
  author    = {Xiaofeng Shi and Lulu Zhao and Hua Zhou and Donglin Hao and Yonghua Lin},
  year      = {2024},
  publisher = {Hugging Face},
  doi       = {10.57967/hf/3487},
  url       = {https://huggingface.co/datasets/BAAI/IndustryInstruction}
}

Author & Links

Downloads last month
4
Safetensors
Model size
8B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for XiaofengAlg/Transport-llama3_1_8B_instruct

Finetuned
(3,271)
this model
Quantizations
1 model

Datasets used to train XiaofengAlg/Transport-llama3_1_8B_instruct

Collection including XiaofengAlg/Transport-llama3_1_8B_instruct