当前位置: 首页 > article >正文

reader-lm:小模型 html转markdown

参考:
https://huggingface.co/jinaai/reader-lm-0.5b

在线demo:
https://colab.research.google.com/drive/1wXWyj5hOxEHY6WeHbOwEzYAC0WB1I5uA#scrollTo=0mG9ISzHOuKK

输入网址:https://www.galaxy-geely.com/E5
结果:
在这里插入图片描述
在这里插入图片描述

代码:

# pip install transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
checkpoint = "jinaai/reader-lm-0.5b"

device = "cuda" # for GPU usage or "cpu" for CPU usage
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)

# example html content
html_content = "<html><body><h1>Hello, world!</h1></body></html>"

messages = [{"role": "user", "content": html_content}]
input_text=tokenizer.apply_chat_template(messages, tokenize=False)

print(input_text)

inputs = tokenizer.encode(input_text, return_tensors="pt").to(device)
outputs = model.generate(inputs, max_new_tokens=1024, temperature=0, do_sample=False, repetition_penalty=1.08)

print(tokenizer.decode(outputs[0]))


http://www.kler.cn/news/302778.html

相关文章:

  • SpringBoot开发——整合Spring Data JPA
  • 3D Gaussian Splatting 论文学习
  • (不用互三)AI绘画工具应该如何选择
  • 【C++】——vector模拟实现和迭代器失效问题
  • 查找代码中所有中文
  • 【Vue3】自动化路由配置:Vue3与unplugin-vue-router的完美结合
  • Spring Boot项目中实现OAuth2客户端模式(Client Credentials Grant Type)
  • 计算机毕业设计选题推荐-土地承包管理系统-Java/Python项目实战(亮点:数据可视化分析、账号锁定、智能推荐)
  • oracel数据库中如果一个表在插入数据会影响另外一个表的查询?
  • 借助Aapose.Cells 在 C# 中将 TXT 转换为 JSON
  • R134a制冷剂简介
  • [ESP32]:如何在micropython中添加C库
  • ESP32 UDP 05
  • 计算机网络基本概述
  • 单考一个OCP认证?还是OCP和OCM认证都要考?
  • 基于深度学习的气象图像分类【mobilenet+VGG16+swin_transfomer+PyQt5界面】
  • Docker进入正在运行的容器的命令
  • 大数据Flink(一百一十七):Flink SQL的窗口操作
  • 爆改YOLOv8|使用MobileViTv1替换Backbone
  • 9.13信锐面经
  • 【北京迅为】《STM32MP157开发板使用手册》-第十八章 Debian文件系统
  • JavaScript使用地理位置 API
  • k8s--资源管理
  • js几个常用数组处理函数(或数组对象处理函数)的使用方法
  • 内存分配形式介绍,你知道哪些?
  • proteus+51单片机+AD/DA学习5
  • 性能测试有哪些典型问题?怎样去定位具体原因?
  • numpy03:numpy广播机制,花式索引取值,统计方法,数组的拆分与合并,线性代数方法
  • C++ 左值与右值浅谈
  • 每天一道面试题(9):lock 和 synchronized 区别