Nvidia has agreed to buy artificial intelligence platform Hugging Face in a deal valued at about $12.9bn (£9.5bn), one of the AI chipmaker's biggest acquisitions as it expands into software.