检查其他资源
- 我为这个问题添加了一个非常描述性的标题。
- 我使用集成搜索在LangChain文档中进行了搜索。
- 我使用GitHub搜索查找类似的问题,但没有找到。
- 我确信这是LangChain中的一个bug,而不是我的代码。
- 通过更新到LangChain的最新稳定版本(或特定集成包)无法解决此bug。
示例代码
import torch
from langchain_community.document_loaders import YoutubeAudioLoader
from langchain_community.document_loaders.generic import GenericLoader
from langchain_community.document_loaders.parsers.audio import (
FasterWhisperParser
)
device = 'cuda' if torch.cuda.is_available() else 'cpu'
# float32
compute_type = "float16" if device == 'cuda' else 'int8'
yt_video_url = 'https://www.youtube.com/watch?v=1bUy-1hGZpI&ab_channel=IBMTechnology'
yt_loader_faster_whisper = GenericLoader(
blob_loader=YoutubeAudioLoader([ yt_video_url], '.'),
blob_parser=FasterWhisperParser(device=device)
# no possibility to define compute_type
# Error: ValueError: Requested float16 compute type, but the target device or backend do not support efficient float16 computation.
# blob_parser=FasterWhisperParser(device=device, compute_type=compute_type)
)
yt_data = yt_loader_faster_whisper.load()
错误信息和堆栈跟踪(如果适用)
Traceback (most recent call last):
File "python/helpers/pydev/pydevd.py", line 1551, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "AI-POC/frameworks/langchain/01_chat_with_data/main.py", line 133, in <module>
docs_load()
File "AI-POC/frameworks/langchain/01_chat_with_data/main.py", line 123, in docs_load
get_youtube(use_paid_services=False, faster_whisper=True, wisper_local=False)
File "AI-POC/frameworks/langchain/01_chat_with_data/main.py", line 108, in get_youtube
yt_data = yt_loader_faster_whisper.load()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "AI-POC/.venv/lib/python3.11/site-packages/langchain_core/document_loaders/base.py", line 29, in load
return list(self.lazy_load())
^^^^^^^^^^^^^^^^^^^^^^
File "AI-POC/.venv/lib/python3.11/site-packages/langchain_community/document_loaders/generic.py", line 116, in lazy_load
yield from self.blob_parser.lazy_parse(blob)
File "AI-POC/.venv/lib/python3.11/site-packages/langchain_community/document_loaders/parsers/audio.py", line 467, in lazy_parse
model = WhisperModel(
^^^^^^^^^^^^^
File "AI-POC/.venv/lib/python3.11/site-packages/faster_whisper/transcribe.py", line 145, in __init__
self.model = ctranslate2.models.Whisper(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: Requested float16 compute type, but the target device or backend do not support efficient float16 computation.
描述
我正在尝试使用langchain_community包中的FasterWhisperParser类解析音频数据。我想能够在有GPU的情况下使用GPU,否则回退到CPU。
我试图在使用GPU时将compute_type设置为'float16',而在使用CPU时将其设置为'int8'。然而,我遇到了一个问题,因为FasterWhisperParser类不接受compute_type参数。当我尝试使用CPU时,我得到了一个ValueError,因为CPU上不高效地支持'float16'计算。
系统信息
$ python -m langchain_core.sys_info
System Information
------------------
> OS: Linux
> OS Version: #1 SMP PREEMPT_DYNAMIC Thu May 11 15:56:33 UTC 2023
> Python Version: 3.11.6 (main, Oct 3 2023, 00:00:00) [GCC 12.3.1 20230508 (Red Hat 12.3.1-1)]
Package Information
-------------------
> langchain_core: 0.2.11
> langchain: 0.2.6
> langchain_community: 0.2.6
> langsmith: 0.1.83
> langchain_text_splitters: 0.2.2
Packages not installed (Not Necessarily a Problem)
--------------------------------------------------
The following packages were not found:
> langgraph
> langserve
1条答案
按热度按时间kse8i1jr1#
根本原因:
langchain/libs/community/langchain_community/document_loaders/parsers/audio.py
第468行 ee579c7
| | self.model_size, device=self.device, compute_type="float16" |