Safetensors
llama
MonteXiaofeng commited on
Commit
dfd938d
1 Parent(s): d698aec

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +115 -0
README.md ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - BAAI/IndustryInstruction
5
+ - BAAI/IndustryInstruction_Hospitality-Catering
6
+ base_model:
7
+ - meta-llama/Meta-Llama-3.1-8B-Instruct
8
+ ---
9
+
10
+ This model is finetuned on the model llama3.1-8b-instruct using the dataset [BAAI/IndustryInstruction_Artificial-Intelligence](https://huggingface.co/datasets/BAAI/IndustryInstruction_Artificial-Intelligence) dataset, the dataset details can jump to the repo: [BAAI/IndustryInstruction](https://huggingface.co/datasets/BAAI/IndustryInstruction)
11
+
12
+ ## training params
13
+
14
+ The training framework is llama-factory, template=llama3
15
+
16
+ ```
17
+ learning_rate=1e-5
18
+ lr_scheduler_type=cosine
19
+ max_length=2048
20
+ warmup_ratio=0.05
21
+ batch_size=64
22
+ epoch=10
23
+ ```
24
+
25
+ select best ckpt by the evaluation loss
26
+ ## evaluation
27
+
28
+ Duto to there is no evaluation benchmark, we can not eval the model
29
+
30
+ ## How to use
31
+
32
+ ```python
33
+ # !/usr/bin/env python
34
+ # -*- coding:utf-8 -*-
35
+ # ==================================================================
36
+ # [Author] : xiaofeng
37
+ # [Descriptions] :
38
+ # ==================================================================
39
+
40
+ from transformers import AutoTokenizer, AutoModelForCausalLM
41
+ import transformers
42
+ import torch
43
+
44
+
45
+ llama3_jinja = """{% if messages[0]['role'] == 'system' %}
46
+ {% set offset = 1 %}
47
+ {% else %}
48
+ {% set offset = 0 %}
49
+ {% endif %}
50
+
51
+ {{ bos_token }}
52
+ {% for message in messages %}
53
+ {% if (message['role'] == 'user') != (loop.index0 % 2 == offset) %}
54
+ {{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}
55
+ {% endif %}
56
+
57
+ {{ '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] | trim + '<|eot_id|>' }}
58
+ {% endfor %}
59
+
60
+ {% if add_generation_prompt %}
61
+ {{ '<|start_header_id|>' + 'assistant' + '<|end_header_id|>\n\n' }}
62
+ {% endif %}"""
63
+
64
+
65
+ dtype = torch.bfloat16
66
+
67
+ model_dir = "MonteXiaofeng/Hospitality-llama3_1_8B_instruct"
68
+ model = AutoModelForCausalLM.from_pretrained(
69
+ model_dir,
70
+ device_map="cuda",
71
+ torch_dtype=dtype,
72
+ )
73
+
74
+ tokenizer = AutoTokenizer.from_pretrained(model_dir)
75
+ tokenizer.chat_template = llama3_jinja # update template
76
+
77
+ message = [
78
+ {"role": "system", "content": "You are a helpful assistant"},
79
+ {
80
+ "role": "user",
81
+ "content": "请举例说明在住宿与餐饮行业中,灵活用工模式的真实运用场景,以及它如何促进从业者的发展。",
82
+ },
83
+ ]
84
+ prompt = tokenizer.apply_chat_template(
85
+ message, tokenize=False, add_generation_prompt=True
86
+ )
87
+ print(prompt)
88
+ inputs = tokenizer.encode(prompt, add_special_tokens=False, return_tensors="pt")
89
+ prompt_length = len(inputs[0])
90
+ print(f"prompt_length:{prompt_length}")
91
+
92
+ generating_args = {
93
+ "do_sample": True,
94
+ "temperature": 1.0,
95
+ "top_p": 0.5,
96
+ "top_k": 15,
97
+ "max_new_tokens": 512,
98
+ }
99
+
100
+
101
+ generate_output = model.generate(input_ids=inputs.to(model.device), **generating_args)
102
+
103
+ response_ids = generate_output[:, prompt_length:]
104
+ response = tokenizer.batch_decode(
105
+ response_ids, skip_special_tokens=True, clean_up_tokenization_spaces=True
106
+ )[0]
107
+
108
+
109
+ """
110
+ 灵活用工模式在住宿与餐饮行业中的应用场景主要体现在以下几个方面:首先,酒店和餐厅可以根据业务需求灵活调整员工的工作时间和地点,例如,使用灵活用工模式可以让前台接待员工在客流量高峰期工作更多时间,而在低谷期则可以减少工作量,节省人力成本。其次,灵活用工模式还可以帮助企业进行员工培训和提升,例如,通过在线学习平台,员工可以在非工作时间学习新的技能或知识,提高个人能力。最后,灵活用工模式还可以促进员工的发展,例如,通过灵活调度,员工可以有更多的时间和机会从事更有价值的工作,如客户关系管理、创新项目等,提升个人职业发展路径。
111
+ """
112
+ print(f"response:{response}")
113
+
114
+
115
+ ```