from transformers import AutoModel

model = AutoModel.from_pretrained(
    "zc277584121/open-provence-bilingual-zh-en-m3-v1",
    trust_remote_code=True
)

# English Case:
question:str = "What's your favorite Japanese food?"
context:str = """
Work deadlines piled up today, and I kept rambling about budget spreadsheets to my roommate.
Next spring I'm planning a trip to Japan so I can wander Kyoto's markets and taste every regional dish I find.
Sushi is honestly my favourite—I want to grab a counter seat and let the chef serve endless nigiri until I'm smiling through soy sauce.
Later I remembered to water the plants and pay the electricity bill before finally getting some sleep.
"""

result = model.process(
    question=question,
    context=context,
    threshold=0.5,
    show_progress=True,
    return_sentence_metrics=True,
)

print("Pruned context:\\n" + result["pruned_context"])
print("Compression rate:", round(result["compression_rate"], 2))
print("sentence_probabilities:", result["sentence_probabilities"])



# Chinese Case:
question:str = "什么是人工智能?"
context:str = """
人工智能(AI)是通过计算机技术模拟、延伸人类感知、推理、学习等智能,让机器能执行原本需人类智能完成的复杂任务的交叉技术科学。
机器学习是人工智能的一个重要分支,它让计算机系统能够从数据中学习并改进性能,无需显式编程。
深度学习是机器学习的一个子领域,使用多层神经网络。
"""

result = model.process(
    question=question,
    context=context,
    threshold=0.5,
    show_progress=True,
    return_sentence_metrics=True,
)

print("Pruned context:\\n" + result["pruned_context"])
print("Compression rate:", round(result["compression_rate"], 2))
print("sentence_probabilities:", result["sentence_probabilities"])
Downloads last month
96
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support