Views
No views yet
Nova-7B-1M is a specialized version of the powerful Qwen/Qwen2.5-7B-Instruct-1M model. It has been fine-tuned to improve safety alignment and is provided in the efficient GGUF format, making its incredible long-context capabilities accessible on a wider range of hardware, including CPUs.Q4_K_M. This 4-bit quantization method offers a great balance between model size, performance, and inference speed.Nova-7B-1M was created with two primary goals:llama.cpp and its Python bindings. The standard transformers library will not work.llama-cpp-python1# For basic CPU usage
2pip install llama-cpp-python
3
4# Or with hardware acceleration (e.g., OpenBLAS)
5# CMAKE_ARGS="-DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS" pip install --force-reinstall --no-cache-dir llama-cpp-python
6
7from llama_cpp import Llama
8
9# Initialize the Llama model
10# You must set n_ctx to your desired context size.
11# WARNING: A 1M context window will require a very large amount of RAM (>64GB).
12# Adjust n_ctx based on your hardware and needs.
13llm = Llama.from_pretrained(
14 repo_id="AdvRahul/Nova-7B-1M-Q4_K_M-GGUF",
15 filename="nova-7b-1m-Q4_K_M.gguf", # Or the actual filename
16 n_ctx=1000000, # <-- CRUCIAL for long context
17 n_gpu_layers=-1, # Offload all layers to GPU if you have VRAM
18 verbose=False
19)
20
21# Qwen chat template
22messages = [
23 {"role": "system", "content": "You are a helpful assistant."},
24 {"role": "user", "content": "Summarize the key points of the provided text."} # Imagine you've loaded a very long document into the prompt
25]
26
27# Use the tokenizer from the loaded model to apply the template
28prompt = llm.tokenizer().apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
29
30# Run inference
31output = llm(
32 prompt,
33 max_tokens=512,
34 stop=["<|im_end|>"],
35 echo=False
36)
37
38print(output['choices'][0]['text'])
39
40⚠️ Ethical Considerations and Limitations
41While this model has been explicitly fine-tuned for safety, no model is perfect.
42
43Safety is Not Guaranteed: The safety alignment is an improvement but does not eliminate all risks. The model may still produce undesirable or biased content.
44
45Long Context Hallucinations: In very long contexts, models can sometimes lose focus or "hallucinate" facts. Always verify critical information from the generated output.
46
47Hardware Demands: While GGUF makes this model more accessible, using the full 1M token context window is extremely RAM-intensive. Users should be aware of the hardware requirements before attempting to process such long sequences.
48
49Developers should always implement their own safety guardrails and content moderation systems as part of a responsible AI deployment strategy.
50