This paper presents a probabilistic approach to string transformation, enhancing both accuracy and efficiency for various applications in natural language processing and information retrieval, particularly focusing on spelling error correction and query reformulation. It introduces a log-linear model, a training method, and a generation algorithm that delivers optimal output even without a predefined dictionary. Experimental results demonstrate significant improvements over existing methods in large-scale datasets.