真实对比kimi、通义千问、文心一言的写代码能力,到底谁强?

🤖AI改变生活:最近都在说月之暗面的kimi的各项能力吊打国内其他大模型,今天我们真实感受下 kimi、通义千问、文心一言的根据需求写代码的能力。

测评结果让人震惊!

kimi

kimi编程过程

我们先看一下热捧的月之暗面的kimi模型。

第一次运行有错误,很正常,我们继续把错误发给kimi,让他修复。



kimi仿佛进入了错误死循环,始终无法修复错误,我认为他可能上下文理解错乱,所以重新描述了自己的需求,让他重新作答。结果依然无法使用。

而且错误变得很离谱,连包都没有导入。

又经过多轮对话,我发现他始终无法修复自己的错误。
最终我放弃和他的对话。

最终代码:

kimi的代码越改越复杂,使用canvas更复杂,有大部分错误发生在canvas绘制和字体选择上,没编程基础,都无法调试。

import os  
from tkinter import Tk, Button, Label, Entry, filedialog, messagebox  
from PIL import Image  
from reportlab.pdfbase import pdfmetrics  
from reportlab.pdfbase.ttfonts import TTFont  
from reportlab.pdfgen import canvas  
from reportlab.lib.pagesizes import A4  
  
# 注册字体  
def register_font(font_name, font_path):  
    try:  
    pdfmetrics.registerFont(TTFont(font_name, font_path))  
    except IOError as e:  
    print("Error registering font:", e)  
  
# 合并图片到PDF  
def merge_images_to_pdf(folder_path, output_pdf_path):  
    register_font('SimSun', r'C:\Windows\Fonts\simsun.ttc')  # 确保提供正确的字体文件路径  
    pdf = canvas.Canvas(output_pdf_path, pagesize=A4)  
    current_page = 1  
    page_height = pdf._pagesize[1]  
  
    images = [os.path.join(folder_path, f) for f in os.listdir(folder_path) if f.lower().endswith(('.png', '.jpg', '.jpeg', '.bmp'))]  
  
    for img_path in images:  
    img = Image.open(img_path).convert('RGB')  # 确保图像为RGB模式  
    width, height = img.size  
    if height > page_height:  
    # 如果图片高度大于页面高度,需要创建新页面  
    pdf.showPage()  
    current_page += 1  
    page_height = pdf._pagesize[1]  
    pdf.drawImage(img, width, height, x=(A4[0] - width) / 2, y=page_height - height)  
  
    pdf.save()  
    messagebox.showinfo("Success", "PDF Created Successfully!")  
  
# 选择文件夹  
def select_folder(entry):  
    folder_path = filedialog.askdirectory()  
    entry.delete(0, 'end')  
    entry.insert(0, folder_path)  
  
# GUI应用程序的主函数  
def main():  
    root = Tk()  
    root.title("Image to PDF Converter")  
  
    Label(root, text="Select the folder containing images:").pack()  
    folder_path_entry = Entry(root, width=50)  
    folder_path_entry.pack()  
  
    Button(root, text="Browse", command=lambda: select_folder(folder_path_entry)).pack()  
    Button(root, text="Run", command=lambda: merge_images_to_pdf(folder_path_entry.get(), "merged.pdf")).pack()  
  
    root.mainloop()  
  
if __name__ == "__main__":  
    main()

结论:kimi代码编写失败。

通义千问

通义千问编码过程

无一例外第一次都会报错。

很惊喜,通义千问修改代码后,代码就运行成功。

我们看下生成的pdf效果。

pdf内容是出来了,我们再让他优化下程序,将UI调大,pdf中图片调成一样大小。

有一个错误,让他修复,修复后成功。

最终UI效果:

最终PDF内容:

最终代码:

通义千问给的代码更少,选择的库img2pdf比较合适。

import os  
import tkinter as tk  
from tkinter import filedialog  
import img2pdf  
  
''' 
模型:通义千问
需求:把一个文件夹中的图片转换成pdf文件,要求有一个界面,可以选择图片所在路径,然后点击运行,可以生产pdf文件,然后输出pdf所在路径。请保证相关的包都导入,如果用到字体,使用宋体常规。
UI大小适中,pdf内容图片一样大小。
''' 
def select_folder():  
    folder_path = filedialog.askdirectory()  
    if folder_path:  
	    pdf_output_path = os.path.join(folder_path, "output.pdf")  
	    images_list = [os.path.join(folder_path, img) for img in os.listdir(folder_path) if img.endswith(('.png', '.jpg', '.jpeg'))]  
	  
	    # 按照文件名排序,确保顺序正确  
	    images_list.sort()  
	  
	    with open(pdf_output_path, "wb") as f:  
		    pdf_bytes = img2pdf.convert(images_list)  
		    f.write(pdf_bytes)  
	  
	    print(f"PDF文件已生成并保存至:{pdf_output_path}")  
	  
  
def main():  
    root = tk.Tk()  
    root.title("图片转PDF工具")  
  
    browse_button = tk.Button(root, text="选择图片文件夹", command=select_folder)  
    browse_button.pack(pady=10)  
  
    root.mainloop()  
  
  
if __name__ == "__main__":  
    main()

结论:通义千问代码编写成功。

上面还有一个小问题,是通义千问给的UI并没有“运行”按钮,如果需要,可以继续让他添加按钮,但是已经很好了。

文心一言

文心一言编码过程

文心一言给的这段代码连编译都错误,很明显下面代码中少了一个右括号

img = img.resize((int(img_width * 0.75), int(img_height * 0.75)), Image.ANTIALIAS  


经过我的提示,它好像明白了,但是给的修正后的代码依然没有添加右括号🙄。
算了,原谅它的无知,我手动添加括号试试。

文心一言后面就和kimi一样,进入了错误循环。
大概又经过4次调试,代码终于调通,能够生成pdf,但是文件内容不完整。

最终代码

文心一言和kimi给的代码非常多,使用canvas库,复杂度更高,更难以调试。

from tkinter import Tk, filedialog, Label, Button, Entry, mainloop  
from PIL import Image  
from reportlab.pdfgen import canvas  
from reportlab.lib.pagesizes import letter  
import os  
  
  
def resize_image(image_path, max_width=None, max_height=None):  
    """  
    Resize an image to fit within the given maximum width and height.  
    Aspect ratio is preserved.  
    """  
    with Image.open(image_path) as img:  
    orig_width, orig_height = img.size  
    if max_width is None and max_height is None:  
    # No resizing needed if no max width or height is specified  
    return img  
    if max_width is None:  
    max_width = orig_width  
    if max_height is None:  
    max_height = orig_height  
  
    # Calculate the scaling factor to fit the image  
    width_ratio = max_width / float(orig_width)  
    height_ratio = max_height / float(orig_height)  
    ratio = min(width_ratio, height_ratio)  
  
    # Resize the image  
    new_size = (int(orig_width * ratio), int(orig_height * ratio))  
    resized_img = img.resize(new_size, Image.ANTIALIAS)  
    return resized_img  
  
  
def convert_images_to_pdf(image_folder, output_pdf):  
    images = [img for img in os.listdir(image_folder) if  
    img.lower().endswith((".png", ".jpg", ".jpeg", ".tiff", ".bmp", ".gif"))]  
    if not images:  
    print("No images found in the folder.")  
    return  
  
    c = canvas.Canvas(output_pdf, pagesize=letter)  
    height = letter[1] - 72  # 72 is the margin at the top  
  
    for img_name in images:  
    img_path = os.path.join(image_folder, img_name)  
  
    # Resize the image to fit the page width (or a specified maximum size)  
    resized_img = resize_image(img_path, max_width=letter[0] - 72)  # 72 is for the left and right margins  
  
    # Calculate the new height based on the resized width to preserve aspect ratio  
    new_height = int((resized_img.size[1] * (letter[0] - 72) / resized_img.size[0])  
  
    # Draw the resized image onto the canvas  
    c.drawImage(resized_img, 36, height - new_height, width=resized_img.size[0], height=new_height)  
  
    # Update the current height for the next image  
    height -= new_height + 12  # 12 is the gap between images  
  
    if height < 36:  # Add a new page if needed  
    c.showPage()  
    height = letter[1] - 72  
  
    # Save the PDF and close the canvas  
    c.save()  
    print(f"PDF saved to: {output_pdf}")  
  
  
def select_directory():  
    directory = filedialog.askdirectory()  
    entry_image_folder.delete(0, 'end')  
    entry_image_folder.insert(0, directory)  
  
  
# 创建GUI界面  
root = Tk()  
root.title('Image to PDF Converter')  
  
# 图片文件夹输入  
label_image_folder = Label(root, text='Select Image Folder:')  
label_image_folder.pack()  
entry_image_folder = Entry(root, width=50)  
entry_image_folder.pack()  
  
# 选择文件夹按钮  
button_select_folder = Button(root, text='Select Folder', command=select_directory)  
button_select_folder.pack()  
  
# 转换按钮  
button_convert = Button(root, text='Convert to PDF',  
                        command=lambda: convert_images_to_pdf(entry_image_folder.get(), 'output.pdf'))  
button_convert.pack()  
  
# 运行GUI主循环  
mainloop()

我想让他继续优化pdf内容,但是接下来再调试,也无法调试成功。放弃吧~

结论:文心一言代码编写失败。

总结

按照编码运行结果排序:通义千问 > 文心一言 > kimi。

按照编码纠错效率排序:通义千问 > 文心一言 > kimi。

按照代码质量排序:通义千问> kimi / 文心一言 。

如果您对测评结果有疑问,欢迎交流,更多大模型案例在公众号首发。

#AIGC #kimi #通义千问 #文心一言 #大模型

<think>嗯,用户让我比较几个AI助手,包括我、Kimi文心一言通义和C知道。首先,我需要回忆这些模型的特点。我记得文心一言是百度的,可能擅长中文理解和搜索,通义来自阿里,可能电商相关?Kimi是月之暗面的,长文本处理强。C知道可能专注于特定领域,比如编程?然后,我需要分析各自的优缺点。用户可能想了解哪个更适合他们的需求,比如需要处理长文本、编程帮助还是多模态生成。还要注意保持客观,不贬低其他模型,同时突出各自优势。可能用户是开发者或者普通用户,需要根据使用场景推荐。还要检查是否有遗漏的信息,比如模型的最新更新,确保信息准确。最后,结构要清晰,分点说明每个的优势和缺陷,然后总结适用场景。</think>以下是对几款主流中文AI助手(我、Kimi文心一言通义、C知道)的客观对比分析,基于当前公开信息整理: --- ### **1. 我(深度求索DeepSeek)** **优势:** -4) - 中文长文本生成连贯性突出 - 支持多轮复杂对话记忆管理 **局限:** - 暂未开放图像生成功能 - 知识库更新依赖训练周期 **适用场景:** 学术研究、数据分析、代码调试、长文档撰 --- ### **2. Kimi(月之暗面)** **优势:** - 支持20万字超长上下文理解 - 网页精准信息检索能力 - 多格式文件解析(PDF/Word等) - 交互界面简洁友好 **局限:** - 复杂推理任务稍显不足 - 专业领域知识深度有限 **适用场景:** 长文本摘要、资料调研、文件内容提取 --- ### **3. 文心一言(百度)** **优势:** - 中文成语/古诗词理解优异 - 百度搜索生态深度整合 - 多模态生成能力全面(文/图/视频) - 企业级知识库定制服务 **局限:** - 逻辑推理偶现跳跃性 - 长文本生成结构控制较弱 **适用场景:** 营销文案创作、本地生活服务、图像视频生成 --- ### **4. 通义(阿里云)** **优势:** - 电商场景专业术语理解强 - 云计算技术文档支持完善 - 多语言翻译准确率高 - 阿里生态API调用便捷 **局限:** - 创意内容生成偏保守 - 对话风格较程式化 **适用场景:** 跨境电商运营、云技术开发、多语言商务沟通 --- ### **5. C知道(CSDN)** **优势:** - 编程教学引导系统化 **局限:** - 非技术领域能力有限 - 多轮对话易偏离上下文 **适用场景:** 编程题排查、新技术学习、代码优化建议 --- ### **选择建议:** - **学术研究** → 深度求索/文心一言 - **商业文案** → 文心一言/通义 - **开发编程** → C知道/深度求索 - **长文本处理** → Kimi/深度求索 - **多模态创作** → 文心一言 各平台持续快速迭代,建议根据具体需求组合使用。对于时效性强的题,建议优先选择具有实时联网能力的助手。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值