diff --git a/chandra/model/hf.py b/chandra/model/hf.py
index 2ef603f..9617cca 100644
--- a/chandra/model/hf.py
+++ b/chandra/model/hf.py
@@ -1,7 +1,6 @@
from typing import List
from qwen_vl_utils import process_vision_info
-from transformers import Qwen3VLForConditionalGeneration, Qwen3VLProcessor
from chandra.model.schema import BatchInputItem, GenerationResult
from chandra.model.util import scale_to_fit
@@ -71,12 +70,15 @@ def process_batch_element(item: BatchInputItem, processor, bbox_scale: int):
def load_model():
+ import torch
+ from transformers import Qwen3VLForConditionalGeneration, Qwen3VLProcessor
+
device_map = "auto"
if settings.TORCH_DEVICE:
device_map = {"": settings.TORCH_DEVICE}
kwargs = {
- "dtype": settings.TORCH_DTYPE,
+ "dtype": torch.bfloat16,
"device_map": device_map,
}
if settings.TORCH_ATTN:
diff --git a/chandra/output.py b/chandra/output.py
index 5cadb89..a8a8b18 100644
--- a/chandra/output.py
+++ b/chandra/output.py
@@ -6,7 +6,7 @@ from functools import lru_cache
import six
from PIL import Image
-from bs4 import BeautifulSoup, NavigableString
+from bs4 import BeautifulSoup
from markdownify import MarkdownConverter, re_whitespace
from chandra.settings import settings
@@ -89,39 +89,6 @@ def parse_html(
return out_html
-def escape_dollars(text):
- return text.replace("$", r"\$")
-
-
-def get_formatted_table_text(element):
- text = []
- for content in element.contents:
- if content is None:
- continue
-
- if isinstance(content, NavigableString):
- stripped = content.strip()
- if stripped:
- text.append(escape_dollars(stripped))
- elif content.name == "br":
- text.append("
")
- elif content.name == "math":
- text.append("$" + content.text + "$")
- else:
- content_str = escape_dollars(str(content))
- text.append(content_str)
-
- full_text = ""
- for i, t in enumerate(text):
- if t == "
":
- full_text += t
- elif i > 0 and text[i - 1] != "
":
- full_text += " " + t
- else:
- full_text += t
- return full_text
-
-
class Markdownify(MarkdownConverter):
def __init__(
self,
diff --git a/chandra/settings.py b/chandra/settings.py
index d0abd1b..ceb06ba 100644
--- a/chandra/settings.py
+++ b/chandra/settings.py
@@ -1,7 +1,5 @@
from dotenv import find_dotenv
-from pydantic import computed_field
from pydantic_settings import BaseSettings
-import torch
import os
@@ -24,11 +22,6 @@ class Settings(BaseSettings):
VLLM_GPUS: str = "0"
MAX_VLLM_RETRIES: int = 6
- @computed_field
- @property
- def TORCH_DTYPE(self) -> torch.dtype:
- return torch.bfloat16
-
class Config:
env_file = find_dotenv("local.env")
extra = "ignore"