初始化项目,由ModelHub XC社区提供模型
Model: huihui-ai/Huihui-LFM2.5-1.2B-Thinking-abliterated Source: Original Platform
This commit is contained in:
35
.gitattributes
vendored
Normal file
35
.gitattributes
vendored
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.model filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||||
|
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||||
41
LICENSE
Normal file
41
LICENSE
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
LICENSE TEXT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
LFM Open License v1.0
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
1. Definitions.
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
|
||||||
|
"Licensor" shall mean Liquid AI, Inc.
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||||
|
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||||
|
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||||
|
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||||
|
"Commercial Use" shall mean any use of the Work for direct or indirect commercial advantage or monetary compensation.
|
||||||
|
"Qualified Non-Profit Organization" shall mean a Legal Entity that is organized and operated exclusively for religious, charitable, scientific, testing for public safety, literary, or educational purposes, and which is exempt from federal income tax under Section 501(c)(3) of the United States Internal Revenue Code of 1986, as amended, or any equivalent non-profit or charitable organization in a foreign jurisdiction.
|
||||||
|
"Non-Commercial or Research Purposes" shall mean purposes that do not involve any use of the Work or a Derivative Work for Commercial Use.
|
||||||
|
"Threshold" shall mean annual revenue of 10 million United States dollars ($10,000,000) or more.
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of this License, including the Commercial Use limitation set forth in Section 5, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of this License, including the Commercial Use limitation set forth in Section 5, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||||
|
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||||
|
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||||
|
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||||
|
5. Commercial Use Limitation.
|
||||||
|
(a) The rights granted under this License for Commercial Use are conditioned upon You or Your Legal Entity not exceeding the Threshold.
|
||||||
|
(b) Any Commercial Use of the Work or a Derivative Work by a Legal Entity that exceeds the Threshold is not licensed under this Agreement.
|
||||||
|
(c) The Threshold shall not apply to a Qualified Non-Profit Organization's use of the Work or a Derivative Work for Non-Commercial or Research Purposes.
|
||||||
|
6. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||||
|
7. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except for the reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
8. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||||
|
9. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||||
|
10. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||||
|
11. Termination. This License will terminate automatically and immediately if You fail to comply with any of its terms and conditions. Upon termination, You must cease all use of the Work and any Derivative Works and delete all copies in Your possession.
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
234
README.md
Normal file
234
README.md
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
---
|
||||||
|
library_name: transformers
|
||||||
|
license: other
|
||||||
|
license_name: lfm1.0
|
||||||
|
license_link: LICENSE
|
||||||
|
language:
|
||||||
|
- en
|
||||||
|
- ar
|
||||||
|
- zh
|
||||||
|
- fr
|
||||||
|
- de
|
||||||
|
- ja
|
||||||
|
- ko
|
||||||
|
- es
|
||||||
|
pipeline_tag: text-generation
|
||||||
|
tags:
|
||||||
|
- liquid
|
||||||
|
- lfm2.5
|
||||||
|
- edge
|
||||||
|
- abliterated
|
||||||
|
- uncensored
|
||||||
|
base_model: LiquidAI/LFM2.5-1.2B-Thinking
|
||||||
|
---
|
||||||
|
|
||||||
|
# huihui-ai/Huihui-LFM2.5-1.2B-Thinking-abliterated
|
||||||
|
|
||||||
|
This is an uncensored version of [LiquidAI/LFM2.5-1.2B-Thinking](https://huggingface.co/LiquidAI/LFM2.5-1.2B-Thinking) created with abliteration (see [remove-refusals-with-transformers](https://github.com/Sumandora/remove-refusals-with-transformers) to know more about it).
|
||||||
|
This is a crude, proof-of-concept implementation to remove refusals from an LLM model without using TransformerLens.
|
||||||
|
|
||||||
|
## ollama
|
||||||
|
|
||||||
|
Q4_K_M may contain duplicates; it is recommended to use the bf16 version.
|
||||||
|
|
||||||
|
You can use [huihui_ai/lfm2.5-abliterated](https://ollama.com/huihui_ai/lfm2.5-abliterated) directly,
|
||||||
|
```
|
||||||
|
ollama run huihui_ai/lfm2.5-abliterated
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
You can use this model in your applications by loading it with Hugging Face's `transformers` library:
|
||||||
|
|
||||||
|
|
||||||
|
```python
|
||||||
|
from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer
|
||||||
|
import torch
|
||||||
|
import os
|
||||||
|
import signal
|
||||||
|
import random
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
|
||||||
|
cpu_count = os.cpu_count()
|
||||||
|
print(f"Number of CPU cores in the system: {cpu_count}")
|
||||||
|
half_cpu_count = cpu_count // 2
|
||||||
|
os.environ["MKL_NUM_THREADS"] = str(half_cpu_count)
|
||||||
|
os.environ["OMP_NUM_THREADS"] = str(half_cpu_count)
|
||||||
|
torch.set_num_threads(half_cpu_count)
|
||||||
|
|
||||||
|
print(f"PyTorch threads: {torch.get_num_threads()}")
|
||||||
|
print(f"MKL threads: {os.getenv('MKL_NUM_THREADS')}")
|
||||||
|
print(f"OMP threads: {os.getenv('OMP_NUM_THREADS')}")
|
||||||
|
|
||||||
|
# Load the model and tokenizer
|
||||||
|
NEW_MODEL_ID = "huihui-ai/Huihui-LFM2.5-1.2B-Thinking-abliterated"
|
||||||
|
print(f"Load Model {NEW_MODEL_ID} ... ")
|
||||||
|
|
||||||
|
model = AutoModelForCausalLM.from_pretrained(
|
||||||
|
NEW_MODEL_ID,
|
||||||
|
device_map="auto",
|
||||||
|
trust_remote_code=True,
|
||||||
|
torch_dtype=torch.bfloat16,
|
||||||
|
low_cpu_mem_usage=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
tokenizer = AutoTokenizer.from_pretrained(NEW_MODEL_ID, trust_remote_code=True)
|
||||||
|
|
||||||
|
messages = []
|
||||||
|
nothink = False
|
||||||
|
skip_prompt=True
|
||||||
|
skip_special_tokens=True
|
||||||
|
|
||||||
|
class CustomTextStreamer(TextStreamer):
|
||||||
|
def __init__(self, tokenizer, skip_prompt=True, skip_special_tokens=True):
|
||||||
|
super().__init__(tokenizer, skip_prompt=skip_prompt, skip_special_tokens=skip_special_tokens)
|
||||||
|
self.generated_text = ""
|
||||||
|
self.stop_flag = False
|
||||||
|
self.init_time = time.time() # Record initialization time
|
||||||
|
self.end_time = None # To store end time
|
||||||
|
self.first_token_time = None # To store first token generation time
|
||||||
|
self.think_tokens_count = 0 # To track total think tokens
|
||||||
|
self.token_count = 0 # To track total tokens
|
||||||
|
|
||||||
|
def on_finalized_text(self, text: str, stream_end: bool = False):
|
||||||
|
if self.first_token_time is None and text.strip(): # Set first token time on first non-empty text
|
||||||
|
self.first_token_time = time.time()
|
||||||
|
self.generated_text += text
|
||||||
|
|
||||||
|
self.token_count += 1
|
||||||
|
if self.think_tokens_count == 0 and "</think>" in self.generated_text:
|
||||||
|
self.think_tokens_count = self.token_count
|
||||||
|
print(text, end="", flush=True)
|
||||||
|
if stream_end:
|
||||||
|
self.end_time = time.time() # Record end time when streaming ends
|
||||||
|
if self.stop_flag:
|
||||||
|
raise StopIteration
|
||||||
|
|
||||||
|
def stop_generation(self):
|
||||||
|
self.stop_flag = True
|
||||||
|
self.end_time = time.time() # Record end time when generation is stopped
|
||||||
|
|
||||||
|
def get_metrics(self):
|
||||||
|
"""Returns initialization time, first token time, first token latency, end time, total time, total tokens, and tokens per second."""
|
||||||
|
if self.end_time is None:
|
||||||
|
self.end_time = time.time() # Set end time if not already set
|
||||||
|
total_time = self.end_time - self.init_time # Total time from init to end
|
||||||
|
tokens_per_second = self.token_count / total_time if total_time > 0 else 0
|
||||||
|
first_token_latency = (self.first_token_time - self.init_time) if self.first_token_time is not None else None
|
||||||
|
metrics = {
|
||||||
|
"init_time": self.init_time,
|
||||||
|
"first_token_time": self.first_token_time,
|
||||||
|
"first_token_latency": first_token_latency,
|
||||||
|
"end_time": self.end_time,
|
||||||
|
"total_time": total_time, # Total time in seconds
|
||||||
|
"think_tokens_count": self.think_tokens_count,
|
||||||
|
"total_tokens": self.token_count,
|
||||||
|
"tokens_per_second": tokens_per_second
|
||||||
|
}
|
||||||
|
return metrics
|
||||||
|
|
||||||
|
def generate_stream(model, tokenizer, messages, nothink, skip_prompt, skip_special_tokens, max_new_tokens):
|
||||||
|
text = tokenizer.apply_chat_template(
|
||||||
|
messages,
|
||||||
|
tokenize=False,
|
||||||
|
add_generation_prompt=True,
|
||||||
|
)
|
||||||
|
model_inputs = tokenizer(
|
||||||
|
[text],
|
||||||
|
return_tensors="pt",
|
||||||
|
).to(model.device)
|
||||||
|
|
||||||
|
streamer = CustomTextStreamer(tokenizer, skip_prompt=skip_prompt, skip_special_tokens=skip_special_tokens)
|
||||||
|
|
||||||
|
def signal_handler(sig, frame):
|
||||||
|
streamer.stop_generation()
|
||||||
|
print("\n[Generation stopped by user with Ctrl+C]")
|
||||||
|
|
||||||
|
signal.signal(signal.SIGINT, signal_handler)
|
||||||
|
|
||||||
|
print("Response: ", end="", flush=True)
|
||||||
|
try:
|
||||||
|
generated_ids = model.generate(
|
||||||
|
**model_inputs,
|
||||||
|
max_new_tokens = max_new_tokens,
|
||||||
|
streamer=streamer,
|
||||||
|
)
|
||||||
|
del generated_ids
|
||||||
|
except StopIteration:
|
||||||
|
print("\n[Stopped by user]")
|
||||||
|
|
||||||
|
del model_inputs
|
||||||
|
torch.cuda.empty_cache()
|
||||||
|
signal.signal(signal.SIGINT, signal.SIG_DFL)
|
||||||
|
|
||||||
|
return streamer.generated_text, streamer.stop_flag, streamer.get_metrics()
|
||||||
|
|
||||||
|
|
||||||
|
while True:
|
||||||
|
print(f"\nnothink: {nothink}")
|
||||||
|
print(f"skip_prompt: {skip_prompt}")
|
||||||
|
print(f"skip_special_tokens: {skip_special_tokens}")
|
||||||
|
|
||||||
|
user_input = input("User: ").strip()
|
||||||
|
if user_input.lower() == "/exit":
|
||||||
|
print("Exiting chat.")
|
||||||
|
break
|
||||||
|
if user_input.lower() == "/clear":
|
||||||
|
messages = []
|
||||||
|
print("Chat history cleared. Starting a new conversation.")
|
||||||
|
continue
|
||||||
|
if user_input.lower() == "/nothink":
|
||||||
|
nothink = not nothink
|
||||||
|
continue
|
||||||
|
if user_input.lower() == "/skip_prompt":
|
||||||
|
skip_prompt = not skip_prompt
|
||||||
|
continue
|
||||||
|
if user_input.lower() == "/skip_special_tokens":
|
||||||
|
skip_special_tokens = not skip_special_tokens
|
||||||
|
continue
|
||||||
|
if not user_input:
|
||||||
|
print("Input cannot be empty. Please enter something.")
|
||||||
|
continue
|
||||||
|
|
||||||
|
messages.append({"role": "user", "content": user_input})
|
||||||
|
|
||||||
|
response, stop_flag, metrics = generate_stream(model, tokenizer, messages, nothink, skip_prompt, skip_special_tokens, 40960)
|
||||||
|
print("\n\nMetrics:")
|
||||||
|
for key, value in metrics.items():
|
||||||
|
print(f" {key}: {value}")
|
||||||
|
|
||||||
|
|
||||||
|
print("", flush=True)
|
||||||
|
if stop_flag:
|
||||||
|
continue
|
||||||
|
messages.append({"role": "assistant", "content": response})
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Usage Warnings
|
||||||
|
|
||||||
|
|
||||||
|
- **Risk of Sensitive or Controversial Outputs**: This model’s safety filtering has been significantly reduced, potentially generating sensitive, controversial, or inappropriate content. Users should exercise caution and rigorously review generated outputs.
|
||||||
|
|
||||||
|
- **Not Suitable for All Audiences**: Due to limited content filtering, the model’s outputs may be inappropriate for public settings, underage users, or applications requiring high security.
|
||||||
|
|
||||||
|
- **Legal and Ethical Responsibilities**: Users must ensure their usage complies with local laws and ethical standards. Generated content may carry legal or ethical risks, and users are solely responsible for any consequences.
|
||||||
|
|
||||||
|
- **Research and Experimental Use**: It is recommended to use this model for research, testing, or controlled environments, avoiding direct use in production or public-facing commercial applications.
|
||||||
|
|
||||||
|
- **Monitoring and Review Recommendations**: Users are strongly advised to monitor model outputs in real-time and conduct manual reviews when necessary to prevent the dissemination of inappropriate content.
|
||||||
|
|
||||||
|
- **No Default Safety Guarantees**: Unlike standard models, this model has not undergone rigorous safety optimization. huihui.ai bears no responsibility for any consequences arising from its use.
|
||||||
|
|
||||||
|
|
||||||
|
### Donation
|
||||||
|
|
||||||
|
If you like it, please click 'like' and follow us for more updates.
|
||||||
|
You can follow [x.com/support_huihui](https://x.com/support_huihui) to get the latest model information from huihui.ai.
|
||||||
|
|
||||||
|
##### Your donation helps us continue our further development and improvement, a cup of coffee can do it.
|
||||||
|
- bitcoin(BTC):
|
||||||
|
```
|
||||||
|
bc1qqnkhuchxw0zqjh2ku3lu4hq45hc6gy84uk70ge
|
||||||
|
```
|
||||||
|
- Support our work on Ko-fi (https://ko-fi.com/huihuiai)!
|
||||||
45
chat_template.jinja
Normal file
45
chat_template.jinja
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{{- bos_token -}}
|
||||||
|
{%- set keep_past_thinking = keep_past_thinking | default(false) -%}
|
||||||
|
{%- set ns = namespace(system_prompt="") -%}
|
||||||
|
{%- if messages[0]["role"] == "system" -%}
|
||||||
|
{%- set ns.system_prompt = messages[0]["content"] -%}
|
||||||
|
{%- set messages = messages[1:] -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- if tools -%}
|
||||||
|
{%- set ns.system_prompt = ns.system_prompt + ("\n" if ns.system_prompt else "") + "List of tools: [" -%}
|
||||||
|
{%- for tool in tools -%}
|
||||||
|
{%- if tool is not string -%}
|
||||||
|
{%- set tool = tool | tojson -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- set ns.system_prompt = ns.system_prompt + tool -%}
|
||||||
|
{%- if not loop.last -%}
|
||||||
|
{%- set ns.system_prompt = ns.system_prompt + ", " -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
{%- set ns.system_prompt = ns.system_prompt + "]" -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- if ns.system_prompt -%}
|
||||||
|
{{- "<|im_start|>system\n" + ns.system_prompt + "<|im_end|>\n" -}}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- set ns.last_assistant_index = -1 -%}
|
||||||
|
{%- for message in messages -%}
|
||||||
|
{%- if message["role"] == "assistant" -%}
|
||||||
|
{%- set ns.last_assistant_index = loop.index0 -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endfor -%}
|
||||||
|
{%- for message in messages -%}
|
||||||
|
{{- "<|im_start|>" + message["role"] + "\n" -}}
|
||||||
|
{%- set content = message["content"] -%}
|
||||||
|
{%- if content is not string -%}
|
||||||
|
{%- set content = content | tojson -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- if message["role"] == "assistant" and not keep_past_thinking and loop.index0 != ns.last_assistant_index -%}
|
||||||
|
{%- if "</think>" in content -%}
|
||||||
|
{%- set content = content.split("</think>")[-1] | trim -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endif -%}
|
||||||
|
{{- content + "<|im_end|>\n" -}}
|
||||||
|
{%- endfor -%}
|
||||||
|
{%- if add_generation_prompt -%}
|
||||||
|
{{- "<|im_start|>assistant\n" -}}
|
||||||
|
{%- endif -%}
|
||||||
57
config.json
Normal file
57
config.json
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
{
|
||||||
|
"architectures": [
|
||||||
|
"Lfm2ForCausalLM"
|
||||||
|
],
|
||||||
|
"block_auto_adjust_ff_dim": true,
|
||||||
|
"block_dim": 2048,
|
||||||
|
"block_ff_dim": 12288,
|
||||||
|
"block_ffn_dim_multiplier": 1.0,
|
||||||
|
"block_mlp_init_scale": 1.0,
|
||||||
|
"block_multiple_of": 256,
|
||||||
|
"block_norm_eps": 1e-05,
|
||||||
|
"block_out_init_scale": 1.0,
|
||||||
|
"block_use_swiglu": true,
|
||||||
|
"block_use_xavier_init": true,
|
||||||
|
"bos_token_id": 1,
|
||||||
|
"conv_L_cache": 3,
|
||||||
|
"conv_bias": false,
|
||||||
|
"conv_dim": 2048,
|
||||||
|
"conv_use_xavier_init": true,
|
||||||
|
"dtype": "bfloat16",
|
||||||
|
"eos_token_id": 7,
|
||||||
|
"hidden_size": 2048,
|
||||||
|
"initializer_range": 0.02,
|
||||||
|
"intermediate_size": 12288,
|
||||||
|
"layer_types": [
|
||||||
|
"conv",
|
||||||
|
"conv",
|
||||||
|
"full_attention",
|
||||||
|
"conv",
|
||||||
|
"conv",
|
||||||
|
"full_attention",
|
||||||
|
"conv",
|
||||||
|
"conv",
|
||||||
|
"full_attention",
|
||||||
|
"conv",
|
||||||
|
"full_attention",
|
||||||
|
"conv",
|
||||||
|
"full_attention",
|
||||||
|
"conv",
|
||||||
|
"full_attention",
|
||||||
|
"conv"
|
||||||
|
],
|
||||||
|
"max_position_embeddings": 128000,
|
||||||
|
"model_type": "lfm2",
|
||||||
|
"norm_eps": 1e-05,
|
||||||
|
"num_attention_heads": 32,
|
||||||
|
"num_heads": 32,
|
||||||
|
"num_hidden_layers": 16,
|
||||||
|
"num_key_value_heads": 8,
|
||||||
|
"pad_token_id": 0,
|
||||||
|
"rope_theta": 1000000.0,
|
||||||
|
"tie_embedding": true,
|
||||||
|
"transformers_version": "4.57.2",
|
||||||
|
"use_cache": true,
|
||||||
|
"use_pos_enc": true,
|
||||||
|
"vocab_size": 65536
|
||||||
|
}
|
||||||
7
generation_config.json
Normal file
7
generation_config.json
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"_from_model_config": true,
|
||||||
|
"bos_token_id": 1,
|
||||||
|
"eos_token_id": 7,
|
||||||
|
"pad_token_id": 0,
|
||||||
|
"transformers_version": "4.57.2"
|
||||||
|
}
|
||||||
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:2e2aa0e9f76c349ef0d234700b61603e1f80052e85fbce0c0ac0d5abd2f77db1
|
||||||
|
size 2340697904
|
||||||
23
special_tokens_map.json
Normal file
23
special_tokens_map.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"bos_token": {
|
||||||
|
"content": "<|startoftext|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": false,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"eos_token": {
|
||||||
|
"content": "<|im_end|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": false,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
},
|
||||||
|
"pad_token": {
|
||||||
|
"content": "<|pad|>",
|
||||||
|
"lstrip": false,
|
||||||
|
"normalized": false,
|
||||||
|
"rstrip": false,
|
||||||
|
"single_word": false
|
||||||
|
}
|
||||||
|
}
|
||||||
323830
tokenizer.json
Normal file
323830
tokenizer.json
Normal file
File diff suppressed because it is too large
Load Diff
4094
tokenizer_config.json
Normal file
4094
tokenizer_config.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user