Views
No views yet
1import torch
2import deepspeed
3import json
4import os
5from huggingface_hub import login
6
7from model_api import CustomModelHandler # Import your custom handler
8from model_api import format_prompt # Import your prompt formatting function
9
10# Define your instruction and data
11instruction_text = "Translate to German."
12data_text = "Who is Albert Einstein?"
13
14# Model configuration
15hf_token = os.environ["HUGGINGFACE_HUB_TOKEN"]
16login(token=hf_token)
17embedding_type = "ise"
18base_model = "Qwen/Qwen2.5-7B"
19model_path = "Embeddings-Collab/Qwen2.5-7B_ise_emb_SFTv70_from_inst_run_34"
20
21# Initialize the model handler
22handler = CustomModelHandler(
23 model_path,
24 base_model,
25 base_model,
26 model_path,
27 None,
28 0,
29 embedding_type=embedding_type,
30 load_from_checkpoint=True
31)
32
33# Initialize DeepSpeed inference engine
34engine = deepspeed.init_inference(
35 model=handler.model,
36 mp_size=torch.cuda.device_count(), # Number of GPUs
37 dtype=torch.float16,
38 replace_method='auto',
39 replace_with_kernel_inject=False
40)
41handler.model = engine.module
42
43# Load prompt templates
44with open("./data/prompt_templates.json", "r") as f:
45 templates = json.load(f)
46
47template = templates[0]
48instruction_text = format_prompt(instruction_text, template, "system")
49data_text = format_prompt(data_text, template, "user")
50
51# Generate output
52output, inp = handler.call_model_api_batch([instruction_text], [data_text])
53print(output)@inproceedings{
zverev2026aside,
title={{ASIDE}}: Architectural Separation of Instructions and Data in Language Models},
author={Egor Zverev and Evgenii Kortukov and Alexander Panfilov and Alexandra Volkova and Rush Tabesh and Sebastian Lapuschkin and Wojciech Samek and Christoph H. Lampert},
booktitle={The Fourteenth International Conference on Learning Representations},
year={2026},
url={https://openreview.net/forum?id=C81TnwHiRM}
}