Skip to content

Compatibility issues on transformers 5.3.0 #21

Description

@jianchang512

Although the pyproject.toml dependency is transformers>=5.0.0,<6.0.0, there's an error on transformers 5.3.0,(Installing transformers 5.0.0 proceeded without any issues.)

load OpenMOSS-Team/MOSS-Transcribe-Diarize,Subprocess Error: 

transformers.tokenization_utils_tokenizers.TokenizersBackend._patch_mistral_regex() got multiple values for keyword argument 'fix_mistral_regex'

Removing the fix_mistral_regex line from tokenizer_config.json will solve the problem.

  1. It's a problem with form_pretrained().to(dtype=dtype).to(device).eval()
load OpenMOSS-Team/MOSS-Transcribe-Diarize,Subprocess Error:

Cannot copy out of meta tensor; no data! 

Please use torch.nn.Module.to_empty() instead of torch.nn.Module.to() when moving module from meta to a different device.

to(dtype=dtype).to(device). needs to be removed.

However, after solving the above two problems, the output is garbled.

The test audio is in English.

Image

The Python Usage example on the README page is used directly.

import torch
from transformers import AutoModelForCausalLM, AutoProcessor

from moss_transcribe_diarize import parse_transcript
from moss_transcribe_diarize.inference_utils import (
    build_transcription_messages,
    generate_transcription,
    resolve_device,
)

model_id = "OpenMOSS-Team/MOSS-Transcribe-Diarize"
audio_path = "audio.wav"

device = resolve_device("auto")
dtype = torch.bfloat16 if device.type == "cuda" else torch.float32

model = AutoModelForCausalLM.from_pretrained(
    model_id,
    trust_remote_code=True,
    dtype="auto",
).to(dtype=dtype).to(device).eval()
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)

messages = build_transcription_messages(audio_path)
result = generate_transcription(
    model,
    processor,
    messages,
    max_new_tokens=2048,
    do_sample=False,
    device=device,
    dtype=dtype,
)

print(result["text"])

for segment in parse_transcript(result["text"]):
    print(segment.start, segment.end, segment.speaker, segment.text)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions