大模型使用小结

从最开始使用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处理。

相关推荐
小超同学你好15 小时前
Transformer 13. DeepSeek LLM 架构解析:与 LLaMA 以及 Transformer 架构对比
人工智能·语言模型·架构·transformer·llama
xier_ran15 小时前
【第二周】RAG与Agent实战:01提示词工程(Prompt Engineering)核心思想详解
语言模型·prompt
翱翔的苍鹰16 小时前
LangChain是一个主流的大语言模型(LLM)应用开发框架,核心功能是连接大模型与外部资源/工具。
网络·人工智能·python·深度学习·语言模型
智算菩萨17 小时前
ChatGPT等AI工具辅助学术论文写作全流程:从选题、润色到降重的实战指南
论文阅读·gpt·ai·语言模型·ai写作
DamianGao17 小时前
我用 OpenClaw 做了一个 AI 新闻早报,每天自动推送
人工智能·python·语言模型
为你奋斗!18 小时前
Playwright 录屏功能启用离线安装依赖pywin32 pillow
开发语言·chrome·python·语言模型·迁移学习
xier_ran19 小时前
【第二周】 RAG与Agent实战05:提示词优化案例_金融文本分析
大数据·人工智能·语言模型·金融
minstbe1 天前
IC设计私有化AI助手实战:基于Docker+OpenCode+Ollama的数字前端综合增强方案(进阶版)
人工智能·python·语言模型·llama
放下华子我只抽RuiKe51 天前
机器学习全景指南-直觉篇——基于距离的 K-近邻 (KNN) 算法
人工智能·gpt·算法·机器学习·语言模型·chatgpt·ai编程
XuecWu31 天前
Karpathy的AutoResearch与Gemini三层 Agent 架构后的相通设计逻辑
人工智能·深度学习·语言模型·自然语言处理