MIT新技術:AI寫Code更準確!唔怕出錯,勁過人手!

Ai




提升AI生成代碼的準確性

一項新技術能自動引導大型語言模型(LLM)生成符合特定編程語言或其他格式規則的輸出,並確保其無錯誤。

現在,程序員可以利用大型語言模型更快速地生成計算機代碼。然而,這對程序員的幫助僅在於該代碼遵循編程語言的規則,並且不會導致計算機崩潰。

雖然已有一些方法確保LLM生成的文本符合所使用語言的規則,但這些方法往往會扭曲模型的原意,或在處理複雜任務時耗時過長。

麻省理工學院及其他機構的研究人員開發了一種新方法,自動引導LLM生成符合相應語言規則的文本,例如特定的編程語言,並保證無錯誤。他們的方法使得LLM能夠專注於最有可能有效且準確的輸出,同時在過程早期就剔除不太可能的輸出。這種概率方法提高了計算效率。

由於這些效率的提升,研究人員的架構使小型LLM在生成準確、結構正確的輸出方面超越了許多大型模型,應用於分子生物學和機器人學等多個現實世界的案例。

長遠來看,這一新架構可能有助於非專業人士控制AI生成的內容。例如,它可以讓商業人士僅使用自然語言提示來撰寫複雜的SQL查詢,這是一種用於數據庫操作的語言。

“這項工作不僅限於研究,它可以改善編程助手、AI驅動的數據分析和科學發現工具,確保AI生成的輸出既有用又正確,”麻省理工學院研究生及該框架論文的共同首席作者若昂·盧拉(João Loula)表示。

強化結構與意義

控制LLM生成的結構化文本的一種常見方法是檢查整個輸出,例如一段計算機代碼,以確保其有效且不會出錯。如果不符合,使用者必須重新開始,消耗計算資源。

另一方面,程序員可以在過程中隨時檢查輸出。雖然這可以確保代碼符合編程語言並且結構有效,但逐步修正代碼可能會導致其偏離使用者的原意,進而降低準確性。

“強化結構比強化意義要容易得多。我們可以快速檢查某個東西是否符合正確的編程語言,但要檢查其意義則必須執行代碼。我們的工作也是關於處理這些不同類型的信息,”盧拉說。

研究人員的方法涉及將專業知識融入LLM,以引導其朝向最有前景的輸出。這些輸出更有可能遵循使用者定義的結構約束,並且擁有使用者所期望的意義。

“我們並不是在訓練LLM去做這件事,而是將專家的知識與LLM的知識結合起來,這種方法與深度學習中的擴展方式截然不同,”曼辛卡(Mansinghka)補充道。

他們使用一種名為序列蒙特卡羅的方法,使LLM能夠並行生成相互競爭的輸出。該模型根據輸出的潛力動態分配資源給不同的計算線程。

每個輸出都有一個權重,表示其結構有效性和語義準確性的可能性。在計算的每一步中,模型專注於那些權重較高的輸出,並剔除其他輸出。

在某種程度上,這就像LLM有一位專家在旁輔導,以確保其在每一步做出正確的選擇,同時保持對整體目標的專注。使用者指定所需的結構和意義,以及如何檢查輸出,然後研究人員的架構引導LLM完成其餘工作。

“我們已經計算出艱難的數學,無論你想要納入什麼約束,你都將獲得正確的權重。最終,你將得到正確的答案,”盧拉表示。

提升小型模型表現

為了測試他們的方法,研究人員將該框架應用於LLM,讓其生成四類輸出:Python代碼、SQL數據庫查詢、分子結構以及機器人的行動計劃。

與現有方法相比,研究人員的方法在準確性上表現更佳,且所需計算量更少。

以Python代碼生成為例,研究人員的架構使一個小型的開源模型超越了一個專門的商業封閉源模型,後者的體積是前者的兩倍還多。

“我們非常興奮能夠讓這些小型模型表現得超出預期,”盧拉說。

展望未來,研究人員希望使用他們的技術來控制生成文本的更大部分,而不是僅僅處理小片段。他們還希望將這種方法與學習結合,讓模型在控制輸出的同時學會變得更準確。

長期來看,這個項目可能對非技術用戶有更廣泛的應用。例如,它可以與自動數據建模系統結合,並查詢生成的數據庫模型。

這種方法還可以使機器輔助的數據分析系統得以實現,使用者可以與準確模擬數據意義及其問題的軟件進行對話,曼辛卡補充道。

“語言學的一個基本問題是,詞語、短語和句子的意義如何能夠與世界模型相連接,考慮到意義和參照中的不確定性和模糊性。LLM預測可能的標記序列,並未解決這個問題。我們的論文表明,在狹窄的符號領域,從詞語映射到基於意義的分佈在技術上是可行的。這是朝著認知科學、語言學和人工智能中更深層次問題邁出的一小步,這些問題是理解機器如何像我們一樣交流世界所需的,”奧唐奈(O’Donnell)表示。

這項研究部分由加拿大CIFAR AI椅子計劃資助,還有西格爾家庭基金會通過捐贈支持麻省理工學院西格爾家庭智力探索計劃。

這項研究的發展不僅在於技術的突破,更在於它所帶來的潛在影響。隨著AI在各行各業的應用逐漸深入,如何確保這些生成的內容不僅準確且符合使用者的需求,將成為未來的一大挑戰。這一技術的進步,無疑為程序員及非技術用戶提供了新的可能性,值得我們持續關注和探討。

以上文章由特價GPT API KEY所翻譯及撰寫。而圖片則由FLUX根據內容自動生成。

🎬 YouTube Premium 家庭 Plan成員一位 只需 HK$148/年

不用提供密碼、不用VPN、無需轉區
直接升級你的香港帳號 ➜ 即享 YouTube + YouTube Music 無廣告播放

立即升級 🔗

🎨 Nano Banana Pro 圖像生成器|打幾句說話就出圖

想畫人像、產品圖、插畫?SSFuture 圖像生成器支援 Flux Gemini Nano Banana Pro 改圖 / 合成, 打廣東話都得,仲可以沿用上一張圖繼續微調。

🆓 Flux 模型即玩,不用登入
🤖 登入後解鎖 Gemini 改圖
📷 支援上載參考圖再生成
⚡ 每天免費額度任你玩
✨ 即刻玩 AI 畫圖
add hello kitty A full-body studio portrait of an elderly man with a bald head and a long, thick white beard, standing confidently beside a muscular grey pit bull dog. The man wears layered monochromatic olive-green tactical fashion: a quilted asymmetric jacket with mixed textures, loose padded cargo pants, and rugged military-style sneakers. His hands rest casually in his pockets as he gazes thoughtfully to the side, calm and powerful. The dog sits alert at his side, wearing a black studded collar, matching the strong, loyal aesthetic. Minimalist studio background in soft matte olive green, seamless floor and wall. Soft cinematic lighting with subtle shadows, high fashion editorial style, ultra-detailed fabric textures, muted earthy color palette, sharp focus, realistic skin tones, dramatic yet elegant mood, 8K resolution, professional fashion photography, Vogue editorial, modern urban warrior aesthetic. Base Setup
keep 100 percent facial information adherence of the attached image and turn her into a lone night hiker standing in the shallow river at the mouth of the canyon, captured as a live action photograph or movie still, not an illustration or CGI render, with an alluring, confident, quietly sexy mood.

Shot and Camera
Three quarter body shot from slightly low height on the riverbank, placing her on the left third while the water leads into the dark canyon and the star filled sky dominates the top of the frame, preserving the original wide vertical composition.

Identity and Pose
She has a slim athletic build, natural proportions, medium length loose hair, and lightly tanned skin, 8k Photorealistic and hyper realistic. She stands barefoot in the water with one leg forward, hips relaxed, wearing a fitted cropped technical top and separate high waisted trail shorts with an open lightweight jacket slipping off one shoulder, one hand loosely holding a headlamp at her side and the other brushing hair from her face as she looks up at the stars.

Lighting and Environment
Keep the soft starlight and faint glow from the distant horizon, giving a gentle rim on her shoulders and hair while a subtle fill from the reflected sky reveals her features. The canyon walls, river reflections, pebbled shore, and dense star field stay exactly like the reference, with small ripples around her feet grounding her in the water.

Masking and Constraints
Change only by adding the subject and her outfit, keep lighting, perspective, white balance, canyon geometry, and river reflections the same, with realistic scale, body proportions, and clear contact between feet and water surface. Change only the requested element and keep lighting, perspective, white balance, pose, face geometry, body proportions, and silhouette the same, and absolutely avoid added text, painterly or toon styling, CGI look, blown highlights, banding, plastic skin, overly tidy backgrounds, or floating feet while requiring consistent perspective, consistent white balance, subtle film like grain, and physically correct contact shadows and reflections.