microsoft / microsoft/LLMLingua

[Question]: Error when running the tutorial

Open
#214 1 comment 0 reactions 1 assignee View on GitHub

@iofu728 is already working on this.

Since Jul 3, 2025.

question
Dominant language
Python
Stars
6.7k
Forks
428
Avg merge
2d 4h
Merged PRs (30d)
1

Description

Hi, everyone, I am trying to run the folllowing code at https://github.com/microsoft/LLMLingua/blob/main/examples/LLMLingua2.ipynb:

from llmlingua import PromptCompressor
llm_lingua = PromptCompressor(
    model_name="microsoft/llmlingua-2-xlm-roberta-large-meetingbank",
    use_llmlingua2=True,
)

However, it throws the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File c:\Users\zhimi\OneDrive\Documents\GitHub\Software-Engineer-Arena\.venv\Lib\site-packages\transformers\utils\import_utils.py:1976, in _LazyModule._get_module(self, module_name)
   [1975](file:///C:/Users/zhimi/OneDrive/Documents/GitHub/Software-Engineer-Arena/.venv/Lib/site-packages/transformers/utils/import_utils.py:1975) try:
-> [1976](file:///C:/Users/zhimi/OneDrive/Documents/GitHub/Software-Engineer-Arena/.venv/Lib/site-packages/transformers/utils/import_utils.py:1976)     return importlib.import_module("." + module_name, self.__name__)
   [1977](file:///C:/Users/zhimi/OneDrive/Documents/GitHub/Software-Engineer-Arena/.venv/Lib/site-packages/transformers/utils/import_utils.py:1977) except Exception as e:

File ~\AppData\Local\Programs\Python\Python313\Lib\importlib\__init__.py:88, in import_module(name, package)
     [87](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/zhimi/OneDrive/Documents/GitHub/Software-Engineer-Arena/~/AppData/Local/Programs/Python/Python313/Lib/importlib/__init__.py:87)         level += 1
---> [88](https://file+.vscode-resource.vscode-cdn.net/c%3A/Users/zhimi/OneDrive/Documents/GitHub/Software-Engineer-Arena/~/AppData/Local/Programs/Python/Python313/Lib/importlib/__init__.py:88) return _bootstrap._gcd_import(name[level:], package, level)

File <frozen importlib._bootstrap>:1387, in _gcd_import(name, package, level)

File <frozen importlib._bootstrap>:1360, in _find_and_load(name, import_)

File <frozen importlib._bootstrap>:1331, in _find_and_load_unlocked(name, import_)

File <frozen importlib._bootstrap>:935, in _load_unlocked(spec)

File <frozen importlib._bootstrap_external>:1022, in exec_module(self, module)

File <frozen importlib._bootstrap>:488, in _call_with_frames_removed(f, *args, **kwds)

File c:\Users\zhimi\OneDrive\Documents\GitHub\Software-Engineer-Arena\.venv\Lib\site-packages\transformers\models\xlm_roberta\modeling_xlm_roberta.py:43
     [33](file:///C:/Users/zhimi/OneDrive/Documents/GitHub/Software-Engineer-Arena/.venv/Lib/site-packages/transformers/models/xlm_roberta/modeling_xlm_roberta.py:33) from ...modeling_outputs import (
...
   [1980](file:///C:/Users/zhimi/OneDrive/Documents/GitHub/Software-Engineer-Arena/.venv/Lib/site-packages/transformers/utils/import_utils.py:1980)         f" traceback):\n{e}"
   [1981](file:///C:/Users/zhimi/OneDrive/Documents/GitHub/Software-Engineer-Arena/.venv/Lib/site-packages/transformers/utils/import_utils.py:1981)     ) from e

RuntimeError: Failed to import transformers.models.xlm_roberta.modeling_xlm_roberta because of the following error (look up to see its traceback):
partially initialized module 'torch._dynamo' from 'c:\Users\zhimi\OneDrive\Documents\GitHub\Software-Engineer-Arena\.venv\Lib\site-packages\torch\_dynamo\__init__.py' has no attribute 'external_utils' (most likely due to a circular import)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.