Niedersachsen will Wasserverbrauch einschränken – wer mehr verbraucht, soll überproportional mehr zahlen apollo-news.net/niedersachsen-… Die rot-grüne Landesregierung in Niedersachsen will das Wassergesetz ändern, um den Wasserverbrauch zu reduzieren und sich besser auf Hochwasser vorzubereiten. ...
The post Niedersachsen will Wasserverbrauch einschränken – wer mehr verbraucht, soll überproportional mehr

16-Jähriger von Gruppe niedergestochen – Berliner Senat will mit Waffenverboten reagieren apollo-news.net/16-jhriger-von… Seit Samstagabend wird ein Jugendlicher im Krankenhaus behandelt, nachdem er von Unbekannten mit einem Messer verletzt wurde. Bereits vor Ort ...
The post 16-Jähriger von Gruppe niedergestochen – Berliner Senat will mit Waffenverboten reagieren appeared first on Apollo News. #news #press

Eigene Preisgestaltung: Russlands Gold bekommt seine Unabhängigkeit von London de.rt.com/russland/250437-eige… Russland – der zweitgrößte Goldproduzent der Welt – möchte sich von der Abhängigkeit der Goldpreise von der Londoner Börse befreien. Zu diesem Zweck ist geplant, bis Ende des Jahres den Goldhandel an der Sankt Petersburger Börse aufzunehmen. #news #press

Bundespräsident Steinmeier: Koalition sei nach Verfassungsrichterwahl-Debakel „beschädigt“ apollo-news.net/bundesprsident… Bundespräsident Frank-Walter Steinmeier sieht die schwarz-rote Koalition nach der gescheiterten Verfassungsrichterwahl vergangenen Freitag „beschädigt“. Kurzfristig wurde die Abstimmung jedoch von ...
The post Bundespräsident Steinmeier: Koalition sei nach Verfassungsrichterwahl-Debakel

Old Radeon HD 2000/3000/4000 GPUs Still Seeing Open-Source Driver Fixes In 2025

In addition to last minute feature work on the latest AMD RDNA4 graphics cards ahead of the Mesa 25.2 code branching, there's also some new fixes going into Mesa for the open-source Radeon driver code... Coming in this Monday morning by surprise are some fixes for the Radeon HD 2000/3000 series approaching two decades old as well as a fix for the Radeon HD 40…
phoronix.com/news/R600-RV770-F…

in reply to みん🌷

เริ่มไม่อยากไปละเพราะเป็นบัตรยืน ขนาดคอนโอลิเวียเป็นบัตรนั่งยังแอบโดนบังตอนคนข้างหน้ายืนเลย มันมีทางเลือกให้คนตัวเล็กบ้างมั้ยยยยย (ไม่)

📍 : readawrite.com/c/f7ea6974f5fed…

👑 [ ลิงก์อ่านต่อ...ด้านบนเลยค่ะ 👆 ]

🌐 More Other Apps : linktr.ee/sunisayok

—————— ༻・ॐ・༺ ——————
#sunisayok #readAwrite #ธัญวลัย #นิยาย #นิยายวาย #แนะนำนิยายวาย #นิยายวายแนะนำ #วาย #mpreg #นิยายมาแรง #นิยายใหม่ #นิยายรัก #ฟีด #fyp #ชุมชนนักเขียน

บ่น

Sensitive content

Warhammer 40,000: Dawn of War - Definitive Edition to release August 14 gamingonlinux.com/2025/07/warh…

#Warhammer #DawnofWar #RTS #Gaming

RADV Vulkan Video Improvements Make It Into Mesa 25.2 For AMD RDNA4 GPUs

Ahead of the Mesa 25.2 code branching / feature freeze expected later this week, last minute feature additions and other changes continue landing in the codebase for these open-source OpenGL and Vulkan drivers. One of the additions today worth mentioning are continued Vulkan Video improvements for AMD Radeon graphics...
phoronix.com/news/RADV-RDNA4-T…

Der Borussia Dortmund kommt zum Jubiläums des Hemberg-Stadions nach Iserlohn. Hier findet ihr den Link zu den Tickets.#[BVB #Fußball-Freundschaftsspiel #Ticketverkaufstartet]

Intel Mesa Drivers Add Option To Disable Xe3's Variable Register Thread "VRT" Feature

One of the interesting new additions with the upcoming Intel Xe3 integrated and discrete graphics is the Variable Register Thread "VRT" feature. Making use of Variable Register Thread can reduce register splitting, reduce bandwidth consumption, and improve overall performance. More background information on Intel VRT can be found in that aforelinked Phoronix…
phoronix.com/news/Intel-Mesa-V…

อีมิแน้นท์แอร์ รับเกียรติบัตร “องค์กรลดโลกร้อน” ตอกย้ำความมุ่งมั่นสู่การพัฒนาอย่างยั่งยืน ด้วยการใช้เสื้อผ้า CoolMode https://digitalmore.co/อีมิแน้นท์แอร์-รับเกียร/

นิยายญี่ปุ่นต่างโลก สูตรสำเร็จที่ครองใจนักอ่านทั่วโลก https://digitalmore.co/นิยายญี่ปุ่นต่างโลก-สูต/

ลองทำ REST API ให้กับ microsoft/BitNet b1.58 2B4T


Blog ตอนนี้มาเขียน กึ่งบ่นครับ 555 ปกติแล้ว ผมจะใช้ Model จากที่มีใน Ollama นี้เอง แล้วบังเอิญว่าเจอ X ของคนนี้ มันมี Model ของ Microsoft เค้าว่ากันว่ากันว่า Model microsoft/BitNet นี้ Run บน CPU ก็ไหมนะ ถ้าใช้แบบพวก M2 จะไว้ขึ้นอีก

Microsoft just a 1-bit LLM with 2B parameters that can run on CPUs like Apple M2.

BitNet b1.58 2B4T outperforms fp LLaMA 3.2 1B while using only 0.4GB memory versus 2GB and processes tokens 40% faster.

100% opensource. pic.twitter.com/kTeqTs6PHd

— Shubham Saboo (@Saboo_Shubham_) April 18, 2025


และเข้า Model นั้นตัว microsoft/BitNet b1.58 2B4T นั้นเองครับ หลังจากเห็นข่าวมาตอน APR 2025 ผมก็รอว่าจะมีใครสักคนลองเอามาทำใน Ollama ไหมนะ เห็นมีคนถามเหมือนกันนะ แต่รอจนนานและมาจนถึงเดือน 6 ยังไม่มีนะ เลยเอาหวะ เดี๋ยวมาหาทาง Run เองจาก Code และกัน โดยตอนแรก ตั้งโจทย์แบบง่ายๆ เอา Model ขึ้น Container และไปหาอะไรสักตัวที่ทำ Endpoint เข้ากับตัว Open WebUI ได้ก็พอครับ

Table of Contents


เตรียมตัวสำหรับ Run microsoft/BitNet
- Linux จริงๆ ผมลองใน docker นะ


เอา image ของ Python ตั้ง และลงตามนี้เลย
# Use official Python 3.12 imageFROM python:3.12-slim# Install system dependencies for PyTorch and build toolsRUN apt-get update && \ apt-get install -y --no-install-recommends \ build-essential \ cmake \ git \ curl \ ca-certificates \ libopenblas-dev \ libomp-dev \ libssl-dev \ libffi-dev \ wget \ && rm -rf /var/lib/apt/lists/*# (Optional) Set a working directoryWORKDIR /app# Copy your requirements.txt if you have oneCOPY requirements.txt .RUN pip install --upgrade pip && pip install -r requirements.txt
และกำหนด requirement ดังนี้
fastapi==0.110.2uvicorn[standard]==0.29.0transformers==4.52.4torch==2.7.0numpy==1.26.4accelerate==0.29.0
จากนั้นจะ Run แบบปกติ
# Build the imagedocker build -t python-bitNet .# Run the container with port forwarding and mounting your codedocker run -it -p 8888:8888 -v "$PWD":/app python-bitNet /bin/bash
หรือ จะใช้ DevContainer ก็ได้นะ ผมลองใช้อันนี้สะดวกดี

- Windows อันนี้ขั้นตอนเยอะนิดนึงครับ สำหรับคนที่ชอบความท้าทาย


ที่เขียนว่าท้าทาย เพราะผมลองแล้วติดมา 2 week 555 ขา Linux มันแปบเดียวจบ โดยสำหรับใครที่อยากลองต้องมีของตามนี้

  • สำหรับใน Visual Studio ต้องลงส่วนของ C++ เพิ่ม ดังนี้



  • รัน PowerShell ไม่รอด ต้องไป Run ใน Developer Command Prompt for VS 2022 หรือ Developer Command Prompt for VS 2022 เหมือนตัว Terminal ปกติ มัน Set ตัวแปร พวก Path อะไรไม่ครบ จะเจอ Error แนวๆ


Error C1083: Cannot open include file: 'algorithm': No such file or directory

แม้ว่าจะลอง set vcvarsall.bat x64 จะอารมณ์ผีเข้าผีออก บางรอบได้ บางรอบไม่ได้

ปล. vcvarsall.bat
อยู่ใน "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat"


  • set python lib .tlb ใน path > ไม่ใส่จะพัง


fatal error LNK1104: cannot open file 'python312.lib'
และ Set env ให้พร้อม

เขียน Code เรียกใช้ Model จาก Hugging Face


หลังจากหมดปัญหาเรื่อง ENV มาลอง โจทย์ดีกว่า ตอนแรก ผมบอก อยากให้ต่อกับ OpenWebUI ได้ เลยทำมา 2 Version แบบ Command / แบบ API

- แบบ Command


ลองเขียน Code โดยใช้

  • Transformers - เพือดึง pre-trained มาจาก Hugging Face
  • PyTorch (torch) - เพื่อ inference จาก Model ที่ตัว Transformers ดีงมาให้ (ในตอนนี้นะ จริงๆ Spec ที่ Run น่าจะได้เท่านี้แหละ ส่วน Train / Fine Tune) จุดที่ใช้มีหลายส่วน
    - torch_dtype=torch.bfloat16 ใช้ตัวนี้มันกิน Memory น้อย ตอนคำนวณมันจะเอามีทศนิยมแหละ แต่ไม่ละเอียด เท่า FP16
    - return_tensors="pt" ให้ใช้รูปแบบของ PyTorch (pt)
    - to(model.device) ถ้ามีพวก cuda เอามาเสริมความแรงได้


import torchfrom transformers import AutoModelForCausalLM, AutoTokenizermodel_id = "microsoft/bitnet-b1.58-2B-4T"# Load tokenizer and modeltokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained( model_id, torch_dtype=torch.bfloat16, force_download=True,)# Apply the chat templatemessages = [ {"role": "system", "content": "You are a Senior Programmer."}, {"role": "user", "content": "Can you help me with a coding problem?"},]prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)chat_input = tokenizer(prompt, return_tensors="pt").to(model.device)# Generate responsechat_outputs = model.generate(**chat_input, max_new_tokens=50)response = tokenizer.decode(chat_outputs[0][chat_input['input_ids'].shape[-1]:], skip_special_tokens=True)print("\nAssistant Response:", response)ลองแบบ Command Line อันนี้จะเห็นว่า Windows ข้อจำกัดเยอะ
อีก version จริงๆเติม Loop ไป และให้วนถามไปเรื่อยๆ จนกว่าพิมพ์ Thank you BITNET อันนี้ดู Code เต็มๆได้ในนี้

- แบบ API


อันนี้ผมบอกก่อนเลยนะ ว่าไม่ได้ Research ว่ามี Lib อะไรที่ทำได้ ให้ API ของเรา ต่อกัน OpenWebUI ได้เลย ตอนแรก ผมลองไปดูก่อนว่า Open WebUI มันรองรับมาตรฐานการเชื่อมต่อแบบไหน ถ้าเป็นส่วน Text Prompt จะมีส่วน OpenAI / Ollama ตอนนี้ผมปักเลือก OpenAI API เพราะที่เคยลองเล่นตัว dotnet semantic kernel มันจะมีแนว /v1/chat/completions เลยลองเริ่มจากตรงนั้น และลอง Add ใน WebUI และดูว่ามันยิง Path ไหนมาที่ Code ของเราครับ

จากที่ลองมาพบว่ามี API 3 เส้นที่น้อยที่สุดที่ Open WebUI ยิงมาขอเรา ครับ ได้แก่

  • /v1/chat/completions
  • /v1/models
  • /health

อย่างของ /v1/chat/completions ผมก็เติมๆ ตามที่มันฟ้อง + ถาม AI ประมาณนี้
import datetimeimport timeimport uuidfrom fastapi import FastAPI, Requestfrom fastapi.responses import JSONResponsefrom pydantic import BaseModelfrom typing import List, Dict, Optionalimport torchimport uuidfrom datetime import datetimefrom transformers import AutoModelForCausalLM, AutoTokenizerapp = FastAPI()# Load model and tokenizer at startupmodel_id = "microsoft/bitnet-b1.58-2B-4T"tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained( model_id, torch_dtype=torch.bfloat16, force_download=True,)device = "cuda" if torch.cuda.is_available() else "cpu"model = model.to(device)class Message(BaseModel): role: str content: strclass ChatRequest(BaseModel): messages: List[Message] max_new_tokens: Optional[int] = 700class Choice(BaseModel): index: int message: Dict[str, str] finish_reason: strclass ChatResponse(BaseModel): id: str object: str created: int model: str choices: List[Choice]@app.post("/v1/chat/completions", response_model=ChatResponse)async def chat_completions(request: ChatRequest): # Prepare prompt using chat template prompt = tokenizer.apply_chat_template( [msg.dict() for msg in request.messages], tokenize=False, add_generation_prompt=True ) chat_input = tokenizer(prompt, return_tensors="pt").to(model.device) chat_outputs = model.generate(**chat_input, max_new_tokens=request.max_new_tokens) response = tokenizer.decode( chat_outputs[0][chat_input['input_ids'].shape[-1]:], skip_special_tokens=True ) # Return response in OpenAI-compatible format # return JSONResponse({ # "id": f"chatcmpl-{uuid.uuid4().hex[:12]}", # "object": "chat.completion", # "created": int(time.time()), # "model": model_id, # "choices": [ # { # "index": 0, # "message": { # "role": "assistant", # "content": response # }, # "finish_reason": "stop" # } # ] # }) return ChatResponse( id=f"chatcmpl-{uuid.uuid4().hex[:12]}", object="chat.completion", created=int(time.time()), model=model_id, choices=[ Choice( index=0, message={"role": "assistant", "content": response}, finish_reason="stop" ) ] )@app.get("/")def root(): """Root endpoint with API info""" return JSONResponse({ "message": "OpenAI-Compatible API for Open WebUI", "version": "1.0.0", "endpoints": { "models": "/v1/models", "chat": "/v1/chat/completions", "health": "/health" } })@app.get("/health")def health_check(): """Health check endpoint""" return JSONResponse({"status": "healthy", "timestamp": datetime.now().isoformat()})@app.get("/v1/models")def list_models(): """List available models""" return JSONResponse({ "data": [ { "id": model_id, "object": "model", "created": datetime.now().isoformat(), "owned_by": "microsoft", "permission": [] } ] })
ตอนใช้งานผมทำเป็น Docker ไว้ ตอน Build แอบช็อคกับขนาดเกือบ 10 GB

ลองใช้งานจริงและ เชื่อมกับ Open WebUI ลองไว และ CPU พุ่ง 55

จบการลองแบบงูปลาๆ และ ถ้าเจอที่ดีกว่า เดี๋ยวมาเขียน Blog ต่ออีกทีครับ ทักมาแนะนำได้ครับ สำหรับ Code ทั้งหมด ผม Up อยู่ใน Git แล้วครับ github.com/pingkunga/python_mi…

ลองทำ REST API ให้กับ microsoft/BitNet b1.58 2B4T

Blog ตอนนี้มาเขียน กึ่งบ่นครับ 555 ปกติแล้ว ผมจะใช้ Model จากที่มีใน Ollama นี้เอง แล้วบังเอิญว่าเจอ X ของคนนี้ มันมี Model ของ Microsoft เค้าว่ากันว่ากันว่า Model microsoft/BitNet นี้ Run บน CPU ก็ไหมนะ ถ้าใช้แบบพวก M2 จะไว้ขึ้นอีก Microsoft just a 1-bit LLM with 2B parameters that can run on CPUs like Apple M2. BitNet b1.58 2B4T outperforms fp LLaMA 3.2 1B while using only 0.4GB memory versus 2GB and processes tokens…

naiwaen.debuggingsoft.com/2025…


ลองทำ REST API ให้กับ microsoft/BitNet b1.58 2B4T


Blog ตอนนี้มาเขียน กึ่งบ่นครับ 555 ปกติแล้ว ผมจะใช้ Model จากที่มีใน Ollama นี้เอง แล้วบังเอิญว่าเจอ X ของคนนี้ มันมี Model ของ Microsoft เค้าว่ากันว่ากันว่า Model microsoft/BitNet นี้ Run บน CPU ก็ไหมนะ ถ้าใช้แบบพวก M2 จะไว้ขึ้นอีก

Microsoft just a 1-bit LLM with 2B parameters that can run on CPUs like Apple M2.

BitNet b1.58 2B4T outperforms fp LLaMA 3.2 1B while using only 0.4GB memory versus 2GB and processes tokens 40% faster.

100% opensource. pic.twitter.com/kTeqTs6PHd

— Shubham Saboo (@Saboo_Shubham_) April 18, 2025


และเข้า Model นั้นตัว microsoft/BitNet b1.58 2B4T นั้นเองครับ หลังจากเห็นข่าวมาตอน APR 2025 ผมก็รอว่าจะมีใครสักคนลองเอามาทำใน Ollama ไหมนะ เห็นมีคนถามเหมือนกันนะ แต่รอจนนานและมาจนถึงเดือน 6 ยังไม่มีนะ เลยเอาหวะ เดี๋ยวมาหาทาง Run เองจาก Code และกัน โดยตอนแรก ตั้งโจทย์แบบง่ายๆ เอา Model ขึ้น Container และไปหาอะไรสักตัวที่ทำ Endpoint เข้ากับตัว Open WebUI ได้ก็พอครับ

Table of Contents


เตรียมตัวสำหรับ Run microsoft/BitNet
- Linux จริงๆ ผมลองใน docker นะ


เอา image ของ Python ตั้ง และลงตามนี้เลย
# Use official Python 3.12 imageFROM python:3.12-slim# Install system dependencies for PyTorch and build toolsRUN apt-get update && \ apt-get install -y --no-install-recommends \ build-essential \ cmake \ git \ curl \ ca-certificates \ libopenblas-dev \ libomp-dev \ libssl-dev \ libffi-dev \ wget \ && rm -rf /var/lib/apt/lists/*# (Optional) Set a working directoryWORKDIR /app# Copy your requirements.txt if you have oneCOPY requirements.txt .RUN pip install --upgrade pip && pip install -r requirements.txt
และกำหนด requirement ดังนี้
fastapi==0.110.2uvicorn[standard]==0.29.0transformers==4.52.4torch==2.7.0numpy==1.26.4accelerate==0.29.0
จากนั้นจะ Run แบบปกติ
# Build the imagedocker build -t python-bitNet .# Run the container with port forwarding and mounting your codedocker run -it -p 8888:8888 -v "$PWD":/app python-bitNet /bin/bash
หรือ จะใช้ DevContainer ก็ได้นะ ผมลองใช้อันนี้สะดวกดี

- Windows อันนี้ขั้นตอนเยอะนิดนึงครับ สำหรับคนที่ชอบความท้าทาย


ที่เขียนว่าท้าทาย เพราะผมลองแล้วติดมา 2 week 555 ขา Linux มันแปบเดียวจบ โดยสำหรับใครที่อยากลองต้องมีของตามนี้

  • สำหรับใน Visual Studio ต้องลงส่วนของ C++ เพิ่ม ดังนี้



  • รัน PowerShell ไม่รอด ต้องไป Run ใน Developer Command Prompt for VS 2022 หรือ Developer Command Prompt for VS 2022 เหมือนตัว Terminal ปกติ มัน Set ตัวแปร พวก Path อะไรไม่ครบ จะเจอ Error แนวๆ


Error C1083: Cannot open include file: 'algorithm': No such file or directory

แม้ว่าจะลอง set vcvarsall.bat x64 จะอารมณ์ผีเข้าผีออก บางรอบได้ บางรอบไม่ได้

ปล. vcvarsall.bat
อยู่ใน "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat"


  • set python lib .tlb ใน path > ไม่ใส่จะพัง


fatal error LNK1104: cannot open file 'python312.lib'
และ Set env ให้พร้อม

เขียน Code เรียกใช้ Model จาก Hugging Face


หลังจากหมดปัญหาเรื่อง ENV มาลอง โจทย์ดีกว่า ตอนแรก ผมบอก อยากให้ต่อกับ OpenWebUI ได้ เลยทำมา 2 Version แบบ Command / แบบ API

- แบบ Command


ลองเขียน Code โดยใช้

  • Transformers - เพือดึง pre-trained มาจาก Hugging Face
  • PyTorch (torch) - เพื่อ inference จาก Model ที่ตัว Transformers ดีงมาให้ (ในตอนนี้นะ จริงๆ Spec ที่ Run น่าจะได้เท่านี้แหละ ส่วน Train / Fine Tune) จุดที่ใช้มีหลายส่วน
    - torch_dtype=torch.bfloat16 ใช้ตัวนี้มันกิน Memory น้อย ตอนคำนวณมันจะเอามีทศนิยมแหละ แต่ไม่ละเอียด เท่า FP16
    - return_tensors="pt" ให้ใช้รูปแบบของ PyTorch (pt)
    - to(model.device) ถ้ามีพวก cuda เอามาเสริมความแรงได้


import torchfrom transformers import AutoModelForCausalLM, AutoTokenizermodel_id = "microsoft/bitnet-b1.58-2B-4T"# Load tokenizer and modeltokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained( model_id, torch_dtype=torch.bfloat16, force_download=True,)# Apply the chat templatemessages = [ {"role": "system", "content": "You are a Senior Programmer."}, {"role": "user", "content": "Can you help me with a coding problem?"},]prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)chat_input = tokenizer(prompt, return_tensors="pt").to(model.device)# Generate responsechat_outputs = model.generate(**chat_input, max_new_tokens=50)response = tokenizer.decode(chat_outputs[0][chat_input['input_ids'].shape[-1]:], skip_special_tokens=True)print("\nAssistant Response:", response)ลองแบบ Command Line อันนี้จะเห็นว่า Windows ข้อจำกัดเยอะ
อีก version จริงๆเติม Loop ไป และให้วนถามไปเรื่อยๆ จนกว่าพิมพ์ Thank you BITNET อันนี้ดู Code เต็มๆได้ในนี้

- แบบ API


อันนี้ผมบอกก่อนเลยนะ ว่าไม่ได้ Research ว่ามี Lib อะไรที่ทำได้ ให้ API ของเรา ต่อกัน OpenWebUI ได้เลย ตอนแรก ผมลองไปดูก่อนว่า Open WebUI มันรองรับมาตรฐานการเชื่อมต่อแบบไหน ถ้าเป็นส่วน Text Prompt จะมีส่วน OpenAI / Ollama ตอนนี้ผมปักเลือก OpenAI API เพราะที่เคยลองเล่นตัว dotnet semantic kernel มันจะมีแนว /v1/chat/completions เลยลองเริ่มจากตรงนั้น และลอง Add ใน WebUI และดูว่ามันยิง Path ไหนมาที่ Code ของเราครับ

จากที่ลองมาพบว่ามี API 3 เส้นที่น้อยที่สุดที่ Open WebUI ยิงมาขอเรา ครับ ได้แก่

  • /v1/chat/completions
  • /v1/models
  • /health

อย่างของ /v1/chat/completions ผมก็เติมๆ ตามที่มันฟ้อง + ถาม AI ประมาณนี้
import datetimeimport timeimport uuidfrom fastapi import FastAPI, Requestfrom fastapi.responses import JSONResponsefrom pydantic import BaseModelfrom typing import List, Dict, Optionalimport torchimport uuidfrom datetime import datetimefrom transformers import AutoModelForCausalLM, AutoTokenizerapp = FastAPI()# Load model and tokenizer at startupmodel_id = "microsoft/bitnet-b1.58-2B-4T"tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained( model_id, torch_dtype=torch.bfloat16, force_download=True,)device = "cuda" if torch.cuda.is_available() else "cpu"model = model.to(device)class Message(BaseModel): role: str content: strclass ChatRequest(BaseModel): messages: List[Message] max_new_tokens: Optional[int] = 700class Choice(BaseModel): index: int message: Dict[str, str] finish_reason: strclass ChatResponse(BaseModel): id: str object: str created: int model: str choices: List[Choice]@app.post("/v1/chat/completions", response_model=ChatResponse)async def chat_completions(request: ChatRequest): # Prepare prompt using chat template prompt = tokenizer.apply_chat_template( [msg.dict() for msg in request.messages], tokenize=False, add_generation_prompt=True ) chat_input = tokenizer(prompt, return_tensors="pt").to(model.device) chat_outputs = model.generate(**chat_input, max_new_tokens=request.max_new_tokens) response = tokenizer.decode( chat_outputs[0][chat_input['input_ids'].shape[-1]:], skip_special_tokens=True ) # Return response in OpenAI-compatible format # return JSONResponse({ # "id": f"chatcmpl-{uuid.uuid4().hex[:12]}", # "object": "chat.completion", # "created": int(time.time()), # "model": model_id, # "choices": [ # { # "index": 0, # "message": { # "role": "assistant", # "content": response # }, # "finish_reason": "stop" # } # ] # }) return ChatResponse( id=f"chatcmpl-{uuid.uuid4().hex[:12]}", object="chat.completion", created=int(time.time()), model=model_id, choices=[ Choice( index=0, message={"role": "assistant", "content": response}, finish_reason="stop" ) ] )@app.get("/")def root(): """Root endpoint with API info""" return JSONResponse({ "message": "OpenAI-Compatible API for Open WebUI", "version": "1.0.0", "endpoints": { "models": "/v1/models", "chat": "/v1/chat/completions", "health": "/health" } })@app.get("/health")def health_check(): """Health check endpoint""" return JSONResponse({"status": "healthy", "timestamp": datetime.now().isoformat()})@app.get("/v1/models")def list_models(): """List available models""" return JSONResponse({ "data": [ { "id": model_id, "object": "model", "created": datetime.now().isoformat(), "owned_by": "microsoft", "permission": [] } ] })
ตอนใช้งานผมทำเป็น Docker ไว้ ตอน Build แอบช็อคกับขนาดเกือบ 10 GB

ลองใช้งานจริงและ เชื่อมกับ Open WebUI ลองไว และ CPU พุ่ง 55

จบการลองแบบงูปลาๆ และ ถ้าเจอที่ดีกว่า เดี๋ยวมาเขียน Blog ต่ออีกทีครับ ทักมาแนะนำได้ครับ สำหรับ Code ทั้งหมด ผม Up อยู่ใน Git แล้วครับ github.com/pingkunga/python_mi…


เทศกาลวัฒนธรรมและการท่องเที่ยวหูหนาน ประจำปี 2568 เปิดฉาก ณ เมืองเซียงถาน https://digitalmore.co/เทศกาลวัฒนธรรมและการท่/

Lossless Scaling Frame Gen gets a Decky Loader Steam Deck plugin but there's drama gamingonlinux.com/2025/07/loss…

#LosslessScaling #SteamDeck #SteamOS #Linux

in reply to Liam @ GamingOnLinux 🐧🎮

The thing is that I »know« what it says, but tech headings these days have become such a mumbo jumbo shorthand of previously unrelated words that even connecting which words go together is a feat. 🙂

And I'm saying that as someone who has read tech headings since 2000. Maybe I'm just old, and you kids should get off my lawn...

IF I HAD ONE 😬

ในที่สุดก็สร้าง keyboard layout อักษรธรรมอีสานบน Windows ได้
github.com/thep/lanxang/commit…

พยายามทำตามสเปคโดยเริ่มจาก locale builder แต่ MS ไม่รองรับอะไรเกี่ยวกับ Tai Tham เลย สุดท้ายจบที่ยืมโลแคลมลยาฬัมแทน แปลกๆ หน่อย แต่ก็ใช้ป้อนอักษรธรรมได้ :P

แต่มันแปลกที่ MS ออกแบบให้ keyboard layout ต้องอิงโลแคล โดยที่โลแคลระบุได้แค่ "ภาษา" กับ "ดินแดน" ระบุ "อักษร" ก็พอได้ แต่ไม่มี Tai Tham ให้เลือก และถึงจะเลือกอักษรได้ พอใช้เขียน "ภาษาไทย" ใน "ประเทศไทย" มันก็จะซ้ำกับโลแคลไทยอักษรไทยอยู่ดีนะ -"-