大模型使用小结

从最开始使用cursor(免费版)写函数,到现在利用本地模型做简单任务,有几点体会。

1 开源和免费系列差别不大

写代码方面大同小异,可能是因为主要训练素材来自流行的开源代码仓库。gemma3:4b综合表现还行。有不少独立开发者说claude code收费版很厉害,目前还没试过。

2 本地模型适合做编程助理

做安全很多年,不喜欢用云上的模型。简单使用了下程序员助理,问题不大。

我:写python脚本,把html转成word,保留样式

gemma3:

复制代码
from bs4 import BeautifulSoup
from docx import Document
from docx.shared import Inches

def html_to_word(html_file_path, word_file_path):
    """
    Converts an HTML file to a Word document, attempting to preserve styles.

    Args:
        html_file_path (str): Path to the HTML file.
        word_file_path (str): Path to save the generated Word document.
    """

    try:
        with open(html_file_path, 'r', encoding='utf-8') as f:
            html_content = f.read()
    except FileNotFoundError:
        print(f"Error: HTML file not found at {html_file_path}")
        return
    except Exception as e:
        print(f"Error reading HTML file: {e}")
        return
    
    soup = BeautifulSoup(html_content, 'html.parser')

    document = Document()

    # Add styles based on HTML tags and attributes
    for element in soup.find_all():
        if element.name == 'h1':
            document.add_heading(element.text, level=1)
        elif element.name == 'h2':
            document.add_heading(element.text, level=2)
        elif element.name == 'h3':
            document.add_heading(element.text, level=3)
        elif element.name == 'p':
            paragraph = document.add_paragraph(element.text)
            # Add basic paragraph formatting (you can customize this further)
            paragraph.paragraph_format.space_after = Inches(0)  # Adjust spacing as needed
        elif element.name == 'img':
            # Add image (basic implementation - you might need to handle image paths and sizes better)
            document.add_picture(element['src'], width=Inches(4))  # Adjust width as needed
        elif element.name == 'a':
            # Add hyperlink (basic implementation)
            document.add_paragraph(element.text, style='list bullet')
            document.paragraphs[-1].embed(element['href'], 'http', element['href'])

        # Add other styles as needed (e.g., tables, lists, etc.)


    document.save(word_file_path)
    print(f"Word document created successfully at {word_file_path}")


# Example usage:
if __name__ == "__main__":
    html_file = "your_html_file.html"  # Replace with your HTML file path
    word_file = "output.docx"        # Replace with your desired Word file path
    html_to_word(html_file, word_file)

格式挺工整的,但是如果想要功能可用,还要考虑很多问题,比如图片链接等。需要来多几次对话,或者一次想清楚,然后交给AI处理。

相关推荐
Sirius Wu7 小时前
意图&实体ToolCall_Prompt调优
人工智能·机器学习·语言模型·prompt·aigc
zhumin7267 小时前
一种基于人类行为—内分泌映射的大语言模型动态情绪系统:从生理数据标定到虚拟激素驱动决策的工程化框架
人工智能·语言模型·自然语言处理
生成论实验室13 小时前
判断力与六十四卦:AI的第三块基石
人工智能·语言模型·机器人·自动驾驶·安全架构
挂科边缘14 小时前
手把手教你使用 Faster-Whisper 实时语音输入转文本,本地部署教程
人工智能·语言模型·whisper·faster-whisper·实时语音输入转文本
我爱cope15 小时前
【Agent智能体23 | 规划-规划工作流】
人工智能·设计模式·语言模型·职场和发展
生成论实验室15 小时前
降U动力学:用一套原理统一解释21项AI技术
人工智能·语言模型·机器人·自动驾驶·安全架构
樱花的浪漫17 小时前
Typescript、Zod基础
前端·javascript·人工智能·语言模型·自然语言处理·typescript
AI人工智能+17 小时前
药品注册证识别技术利用深度学习和多模态融合架构,实现药品注册证信息的自动化精准提取
深度学习·语言模型·自然语言处理·ocr·药品注册证识别
像风一样自由202018 小时前
量化压缩实战:INT8 / INT4 / AWQ / GPTQ 全面对比
android·人工智能·语言模型·大模型
P-ShineBeam18 小时前
智能体-LangChain框架-Tools工具的使用指南
数据库·人工智能·语言模型·自然语言处理·langchain